]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-656: Implement ES index rebuild at /index/elasticsearch.
authorRay Lee <ray.lee@lyrasis.org>
Fri, 5 Jul 2019 00:27:38 +0000 (17:27 -0700)
committerRay Lee <ray.lee@lyrasis.org>
Fri, 5 Jul 2019 01:57:14 +0000 (18:57 -0700)
services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CSpaceResteasyBootstrap.java
services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml
services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandlerImpl.java
services/common/src/main/java/org/collectionspace/services/common/document/DocumentHandler.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoRepositoryClientImpl.java
services/index/service/src/main/java/org/collectionspace/services/index/nuxeo/IndexDocumentModelHandler.java

index c60dc923a071c4f5d5f39962e785efa592bcd938..82244d93ed6c62039780720c884aabf6995e117c 100644 (file)
@@ -116,12 +116,11 @@ public class CSpaceResteasyBootstrap extends ResteasyBootstrap {
 
                                if (isElasticsearchIndexed && servicesRepoDomainName != null && servicesRepoDomainName.trim().isEmpty() == false) {
                                        String repositoryName = ConfigUtils.getRepositoryName(tenantBinding, servicesRepoDomainName);
-                                       String docType = serviceBinding.getObject().getName();
-                                       String tenantQualifiedDocType = NuxeoUtils.getTenantQualifiedDocType(tenantBinding.getId(), docType);
+                                       String docType = NuxeoUtils.getTenantQualifiedDocType(tenantBinding.getId(), serviceBinding.getObject().getName());
 
-                                       logger.log(Level.INFO, String.format("%tc [INFO] Starting Elasticsearch reindexing for docType %s in repository %s", new Date(), tenantQualifiedDocType, repositoryName));
+                                       logger.log(Level.INFO, String.format("%tc [INFO] Starting Elasticsearch reindexing for docType %s in repository %s", new Date(), docType, repositoryName));
 
-                                       es.runReindexingWorker(repositoryName, String.format("SELECT ecm:uuid FROM %s", tenantQualifiedDocType));
+                                       es.runReindexingWorker(repositoryName, String.format("SELECT ecm:uuid FROM %s", docType));
                                }
                        }
                }
index cd664d914d915d136ba85b155d679414ef67a4f8..c3543c8e076d157a86788951dcf5b77d78d31963 100644 (file)
                </tenant:eventListenerConfig>
            </tenant:eventListenerConfigurations>
                <tenant:properties>
-                       <!-- Controls whether term completion (aka partial term matching, aka autocomplete) searches will automatically insert 
-                               a leading wildcard. The default value is 'true', which will cause your search expression to be matched when found anywhere 
-                               within a term. If this value is set to 'false', searches will only find terms which begin with your search expression. However, 
-                               even with a setting of 'false', you can manually add an asterisk (*) as a wildcard at the beginning of any search; e.g. "*atrick" 
-                               (without quotes) will match the string "atrick" anywhere, not just at the beginning of a term. See the tenant-bindings.delta.xml 
+                       <!-- Controls whether term completion (aka partial term matching, aka autocomplete) searches will automatically insert
+                               a leading wildcard. The default value is 'true', which will cause your search expression to be matched when found anywhere
+                               within a term. If this value is set to 'false', searches will only find terms which begin with your search expression. However,
+                               even with a setting of 'false', you can manually add an asterisk (*) as a wildcard at the beginning of any search; e.g. "*atrick"
+                               (without quotes) will match the string "atrick" anywhere, not just at the beginning of a term. See the tenant-bindings.delta.xml
                                file for the 'testsci' tenant, for examples of how to override this value, and other, similar values below, in your own tenant. -->
                        <types:item id="ptstartingwildcard" merge:matcher="skip" merge:action="insert" xmlns:types="http://collectionspace.org/services/config/types">
                                <types:key>ptStartingWildcard</types:key>
                                <types:value>true</types:value>
                        </types:item>
-                       <!-- By default, term completion searches return a maximum number of terms in their search results. The default value 
+                       <!-- By default, term completion searches return a maximum number of terms in their search results. The default value
                                is 40 terms. -->
                        <types:item id="maxlistitemsjdbc" merge:matcher="skip" merge:action="insert" xmlns:types="http://collectionspace.org/services/config/types">
                                <types:key>maxListItemsReturnedLimitOnJdbcQueries</types:key>
                                <types:value>40</types:value>
                        </types:item>
-                       <!-- By default, term completion searches are restricted (constrained) to the current tenant. On a system where a tenant's 
-                               data is isolated within its own repository, or on a shared repository system where only one tenant has data, this restriction 
-                               can be removed by setting the value below to 'false'. That will remove one SQL JOIN from the query, potentially improving 
+                       <!-- By default, term completion searches are restricted (constrained) to the current tenant. On a system where a tenant's
+                               data is isolated within its own repository, or on a shared repository system where only one tenant has data, this restriction
+                               can be removed by setting the value below to 'false'. That will remove one SQL JOIN from the query, potentially improving
                                search performance. -->
                        <types:item id="jdbcqueriestenantrestricted" merge:matcher="skip" merge:action="insert" xmlns:types="http://collectionspace.org/services/config/types">
                                <types:key>jdbcQueriesAreTenantIdRestricted</types:key>
                 </service:part>
             </service:object>
         </tenant:serviceBindings>
-        <!-- end PublicItem service meta-data -->    
+        <!-- end PublicItem service meta-data -->
 
                <!-- begin servicegroup service meta-data -->
-               <!-- Servicegroup is a task service that has no representation in the repo, but provides tools like keyword search across 
+               <!-- Servicegroup is a task service that has no representation in the repo, but provides tools like keyword search across
                        many types of services. -->
            <tenant:serviceBindings id="servicegroups" merge:matcher="id" name="servicegroups" type="utility" version="1.0">
                        <service:repositoryDomain xmlns:service="http://collectionspace.org/services/config/service">default-domain</service:repositoryDomain>
                        </service:documentHandler>
                </tenant:serviceBindings>
                <!-- end servicegroup service meta-data -->
-           
+
            <!-- begin structureddate service meta-data -->
            <!-- structureddate is a task service that has no representation in the repo, but provides a date string parsing service. -->
            <tenant:serviceBindings id="structureddates" merge:matcher="id" name="structureddates" requiresDocumentHandler="false" type="utility"
                <service:repositoryDomain xmlns:service="http://collectionspace.org/services/config/service">default-domain</service:repositoryDomain>
            </tenant:serviceBindings>
            <!-- end structureddate service meta-data -->
-           
+
            <!-- begin systeminfo service meta-data -->
            <!-- systeminfo is a task service that has no representation in the repo, but system meta data and version. -->
            <tenant:serviceBindings id="systeminfo" merge:matcher="id" name="systeminfo" requiresDocumentHandler="false" type="utility"
                version="1.0">
                <service:repositoryDomain xmlns:service="http://collectionspace.org/services/config/service">default-domain</service:repositoryDomain>
            </tenant:serviceBindings>
-           <!-- end systeminfo service meta-data -->       
+           <!-- end systeminfo service meta-data -->
 
                <!-- begin blob service meta-data -->
                <!-- This should likely be type="object" -->
                        </service:object>
                </tenant:serviceBindings>
                <!-- end Workflow service meta-data -->
-               
+
                <!-- begin Index service meta-data -->
                <tenant:serviceBindings id="Index" merge:matcher="id" name="Index" type="utility"
                        version="1.0">
                        </service:validatorHandler>
                        <service:properties xmlns:service="http://collectionspace.org/services/config/service">
                                <types:item xmlns:types="http://collectionspace.org/services/config/types">
-                         <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>
+                                       <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>
+                                       <!-- %s in value will be substituted with the appropriate doc type -->
+                                       <types:value>SELECT ecm:uuid FROM %s</types:value>
+                               </types:item>
                        </service:properties>
                        <service:object xmlns:service="http://collectionspace.org/services/config/service" name="Index"
                                version="1.0">
                                </service:part>
                        </service:object>
                </tenant:serviceBindings>
-               <!-- end Index service meta-data -->            
+               <!-- end Index service meta-data -->
 
                <!-- begin report service meta-data -->
                <tenant:serviceBindings id="Reports" merge:matcher="id" name="Reports" type="utility" version="1.0">
                        </service:documentHandler>
                        <!-- Configuration of list results fields for relation items is commented out for now, -->
                        <!-- pending resolution of how to specify nested elements in list results. -->
-                       <!-- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/config/service"> <service:params> <service:ListResultsFields> 
-                               <service:ListResultField> <service:element>subjectCsid</service:element> <service:xpath>subjectCsid</service:xpath> </service:ListResultField> 
-                               <service:ListResultField> <service:element>subjectRefName</service:element> <service:xpath>subjectRefName</service:xpath> 
-                               </service:ListResultField> <service:ListResultField> <service:element>relationshipType</service:element> <service:xpath>relationshipType</service:xpath> 
-                               </service:ListResultField> <service:ListResultField> <service:element>predicate</service:element> <service:xpath>predicate</service:xpath> 
-                               </service:ListResultField> <service:ListResultField> <service:element>predicateDisplayName</service:element> <service:xpath>predicateDisplayName</service:xpath> 
-                               </service:ListResultField> <service:ListResultField> <service:element>objectCsid</service:element> <service:xpath>objectCsid</service:xpath> 
-                               </service:ListResultField> <service:ListResultField> <service:element>objectRefName</service:element> <service:xpath>objectRefName</service:xpath> 
-                               </service:ListResultField> <service:ListResultField> <service:element>relationshipType</service:element> <service:xpath>relationshipType</service:xpath> 
+                       <!-- <service:DocHandlerParams xmlns:service="http://collectionspace.org/services/config/service"> <service:params> <service:ListResultsFields>
+                               <service:ListResultField> <service:element>subjectCsid</service:element> <service:xpath>subjectCsid</service:xpath> </service:ListResultField>
+                               <service:ListResultField> <service:element>subjectRefName</service:element> <service:xpath>subjectRefName</service:xpath>
+                               </service:ListResultField> <service:ListResultField> <service:element>relationshipType</service:element> <service:xpath>relationshipType</service:xpath>
+                               </service:ListResultField> <service:ListResultField> <service:element>predicate</service:element> <service:xpath>predicate</service:xpath>
+                               </service:ListResultField> <service:ListResultField> <service:element>predicateDisplayName</service:element> <service:xpath>predicateDisplayName</service:xpath>
+                               </service:ListResultField> <service:ListResultField> <service:element>objectCsid</service:element> <service:xpath>objectCsid</service:xpath>
+                               </service:ListResultField> <service:ListResultField> <service:element>objectRefName</service:element> <service:xpath>objectRefName</service:xpath>
+                               </service:ListResultField> <service:ListResultField> <service:element>relationshipType</service:element> <service:xpath>relationshipType</service:xpath>
                                </service:ListResultField> </service:ListResultsFields> </service:params> </service:DocHandlerParams> -->
-                       <!-- Relation list items can include two additional fields, 'subject' and 'object', each of which are parent elements 
+                       <!-- Relation list items can include two additional fields, 'subject' and 'object', each of which are parent elements
                                of, and hence containers for, as many as eight child fields. See services/jaxb/src/main/resources/relations_common.xsd -->
                        <service:validatorHandler xmlns:service="http://collectionspace.org/services/config/service">org.collectionspace.services.relation.nuxeo.RelationValidatorHandler
                        </service:validatorHandler>
                <tenant:serviceBindings id="Contacts" merge:matcher="id" name="Contacts" type="utility"
                        version="1.0">
                        <!-- other URI paths through which this service could be accessed -->
-                       <!-- <service:uriPath xmlns:service='http://collectionspace.org/services/config/service'> /personauthorities/*/items/*/contacts 
-                               </service:uriPath> <service:uriPath xmlns:service='http://collectionspace.org/services/config/service'> /orgauthorities/*/items/*/contacts 
+                       <!-- <service:uriPath xmlns:service='http://collectionspace.org/services/config/service'> /personauthorities/*/items/*/contacts
+                               </service:uriPath> <service:uriPath xmlns:service='http://collectionspace.org/services/config/service'> /orgauthorities/*/items/*/contacts
                                </service:uriPath> -->
                        <service:repositoryDomain xmlns:service="http://collectionspace.org/services/config/service">default-domain</service:repositoryDomain>
                        <service:documentHandler xmlns:service="http://collectionspace.org/services/config/service">org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler
                                                        <types:key>authRef</types:key>
                                                        <types:value>addressGroupList/*/addressStateOrProvince</types:value>
                                                </types:item>
-                                               <!-- Per CSPACE-5080: This field is configured as a term list, rather than being tied to Place authority as described 
+                                               <!-- Per CSPACE-5080: This field is configured as a term list, rather than being tied to Place authority as described
                                                        in wiki schema -->
-                                               <!--<types:item xmlns:types="http://collectionspace.org/services/config/types"> <types:key>authRef</types:key> <types:value>addressGroupList/*/addressCountry</types:value> 
+                                               <!--<types:item xmlns:types="http://collectionspace.org/services/config/types"> <types:key>authRef</types:key> <types:value>addressGroupList/*/addressCountry</types:value>
                                                        </types:item> -->
                                                <!-- Fields containing term list / controlled vocabulary references -->
                                                <types:item xmlns:types="http://collectionspace.org/services/config/types">
                <tenant:serviceBindings id="authorization/permissions/permroles" merge:matcher="id"
                        name="authorization/permissions/permroles" type="security" version="1.0">
                        <!-- other URI paths through which this service could be accessed -->
-                       <!-- <service:uriPath xmlns:service='http://collectionspace.org/services/config/service'> /authorization/permissions/*/permroles/ 
+                       <!-- <service:uriPath xmlns:service='http://collectionspace.org/services/config/service'> /authorization/permissions/*/permroles/
                                </service:uriPath> -->
                        <service:documentHandler xmlns:service="http://collectionspace.org/services/config/service">org.collectionspace.services.authorization.storage.PermissionRoleDocumentHandler
                        </service:documentHandler>
-                       <!-- <service:validatorHandler xmlns:service='http://collectionspace.org/services/config/service'> org.collectionspace.services.authorization.storage.PermissionRoleValidatorHandler 
+                       <!-- <service:validatorHandler xmlns:service='http://collectionspace.org/services/config/service'> org.collectionspace.services.authorization.storage.PermissionRoleValidatorHandler
                                </service:validatorHandler> -->
                        <service:object xmlns:service="http://collectionspace.org/services/config/service" name="PermissionRole"
                                version="1.0">
                        <!-- <service:uriPath xmlns:service='http://collectionspace.org/services/config/service'> /accounts/*/accountroles/ </service:uriPath> -->
                        <service:documentHandler xmlns:service="http://collectionspace.org/services/config/service">org.collectionspace.services.account.storage.AccountRoleDocumentHandler
                        </service:documentHandler>
-                       <!-- <service:validatorHandler xmlns:service='http://collectionspace.org/services/config/service'> org.collectionspace.services.account.storage.AccountRoleDocumentHandler 
+                       <!-- <service:validatorHandler xmlns:service='http://collectionspace.org/services/config/service'> org.collectionspace.services.account.storage.AccountRoleDocumentHandler
                                </service:validatorHandler> -->
                        <service:object xmlns:service="http://collectionspace.org/services/config/service" name="AccountRole"
                                version="1.0">
                <tenant:serviceBindings id="authorization/roles/permroles" merge:matcher="id"
                        name="authorization/roles/permroles" type="security" version="1.0">
                        <!-- other URI paths through which this service could be accessed -->
-                       <!-- <service:uriPath xmlns:service='http://collectionspace.org/services/config/service'> /authorization/roles/*/permroles/ 
+                       <!-- <service:uriPath xmlns:service='http://collectionspace.org/services/config/service'> /authorization/roles/*/permroles/
                                </service:uriPath> -->
                        <service:documentHandler xmlns:service="http://collectionspace.org/services/config/service">org.collectionspace.services.authorization.storage.PermissionRoleDocumentHandler
                        </service:documentHandler>
-                       <!-- <service:validatorHandler xmlns:service='http://collectionspace.org/services/config/service'> org.collectionspace.services.authorization.storage.PermissionRoleValidatorHandler 
+                       <!-- <service:validatorHandler xmlns:service='http://collectionspace.org/services/config/service'> org.collectionspace.services.authorization.storage.PermissionRoleValidatorHandler
                                </service:validatorHandler> -->
                        <service:object xmlns:service="http://collectionspace.org/services/config/service" name="PermissionRole"
                                version="1.0">
                <tenant:serviceBindings id="authorization/roles/accountroles" merge:matcher="id"
                        name="authorization/roles/accountroles" type="security" version="1.0">
                        <!-- other URI paths through which this service could be accessed -->
-                       <!-- <service:uriPath xmlns:service='http://collectionspace.org/services/config/service'> /authorization/roles/*/accountroles/ 
+                       <!-- <service:uriPath xmlns:service='http://collectionspace.org/services/config/service'> /authorization/roles/*/accountroles/
                                </service:uriPath> -->
                        <service:documentHandler xmlns:service="http://collectionspace.org/services/config/service">org.collectionspace.services.account.storage.AccountRoleDocumentHandler
                        </service:documentHandler>
-                       <!-- <service:validatorHandler xmlns:service='http://collectionspace.org/services/config/service'> org.collectionspace.services.authorization.storage.PermissionRoleValidatorHandler 
+                       <!-- <service:validatorHandler xmlns:service='http://collectionspace.org/services/config/service'> org.collectionspace.services.authorization.storage.PermissionRoleValidatorHandler
                                </service:validatorHandler> -->
                        <service:object xmlns:service="http://collectionspace.org/services/config/service" name="AccountRole"
                                version="1.0">
index 8ffa1d259cd2a18aed10f7011e78543ecc0b8191..aa296e796274dfa976bdc4840ff4b3a2967041b5 100644 (file)
@@ -40,10 +40,10 @@ import org.slf4j.LoggerFactory;
  *
  * $LastChangedRevision: $
  * $LastChangedDate: $
- * @param <T> 
- * @param <TL> 
- * @param <WT> 
- * @param <WTL> 
+ * @param <T>
+ * @param <TL>
+ * @param <WT>
+ * @param <WTL>
  */
 @SuppressWarnings({"unchecked", "rawtypes"})
 public abstract class AbstractDocumentHandlerImpl<T, TL, WT, WTL>
@@ -51,13 +51,13 @@ public abstract class AbstractDocumentHandlerImpl<T, TL, WT, WTL>
 
     /** The logger. */
     private final Logger logger = LoggerFactory.getLogger(AbstractDocumentHandlerImpl.class);
-    
+
     /** The properties. */
     private Map<String, Object> properties = new HashMap<String, Object>();
-    
+
     /** The doc filter. */
     private DocumentFilter docFilter = null;
-    
+
     /** The service context. */
     private ServiceContext serviceContext;
 
@@ -69,12 +69,12 @@ public abstract class AbstractDocumentHandlerImpl<T, TL, WT, WTL>
     }
 
     abstract protected String getRefnameDisplayName(DocumentWrapper<WT> docWrapper);
-        
+
     /*
      * Should return a reference name for the wrapper object
      */
     abstract protected RefName.RefNameInterface getRefName(DocumentWrapper<WT> docWrapper, String tenantName, String serviceName);
-    
+
     /* (non-Javadoc)
      * @see org.collectionspace.services.common.document.DocumentHandler#getServiceContext()
      */
@@ -161,16 +161,16 @@ public abstract class AbstractDocumentHandlerImpl<T, TL, WT, WTL>
                 validate(action);
                 prepareDelete();
                 break;
-                
+
             case SYNC:
                 prepareSync();
                 break;
-                
+
                        case WORKFLOW:
                                logger.error("Should never get to this code path.  If you did, there is a bug in the code.");
                                Thread.dumpStack();
                                break;
-                               
+
                        default:
                                logger.error("Should never get to this code path.  If you did, there is a bug in the code.");
                                Thread.dumpStack();
@@ -227,7 +227,7 @@ public abstract class AbstractDocumentHandlerImpl<T, TL, WT, WTL>
     @Override
     final public boolean handle(Action action, DocumentWrapper<?> wrapDoc) throws Exception {
        boolean result = true;
-       
+
         switch (action) {
             case CREATE:
                 handleCreate((DocumentWrapper<WT>) wrapDoc);
@@ -248,25 +248,25 @@ public abstract class AbstractDocumentHandlerImpl<T, TL, WT, WTL>
             case DELETE:
                 result = handleDelete((DocumentWrapper<WT>) wrapDoc);
                 break;
-                
+
             case SYNC:
                 result = handleSync((DocumentWrapper<Object>) wrapDoc);
-                break;                
-                
+                break;
+
                        case WORKFLOW:
                                logger.error("Should never get to this code path.  If you did, there is a bug in the code.");
                                Thread.dumpStack();
                                break;
-                               
+
                        default:
                                logger.error("Should never get to this code path.  If you did, there is a bug in the code.");
                                Thread.dumpStack();
                                break;
         }
-        
+
         return result;
     }
-    
+
     @Override
        public void sanitize(DocumentWrapper<WT> wrapDoc) {
        //
@@ -306,7 +306,7 @@ public abstract class AbstractDocumentHandlerImpl<T, TL, WT, WTL>
     public boolean handleDelete(DocumentWrapper<WT> wrapDoc) throws Exception {
         return true;
     }
-    
+
     /* (non-Javadoc)
      * @see org.collectionspace.services.common.document.DocumentHandler#handleDelete(org.collectionspace.services.common.document.DocumentWrapper)
      */
@@ -315,7 +315,7 @@ public abstract class AbstractDocumentHandlerImpl<T, TL, WT, WTL>
        // Do nothing. Subclasses can override if they want/need to.
        return true;
     }
-    
+
 
     /* (non-Javadoc)
      * @see org.collectionspace.services.common.document.DocumentHandler#complete(org.collectionspace.services.common.document.DocumentHandler.Action, org.collectionspace.services.common.document.DocumentWrapper)
@@ -342,20 +342,20 @@ public abstract class AbstractDocumentHandlerImpl<T, TL, WT, WTL>
             case DELETE:
                 completeDelete((DocumentWrapper<WT>) wrapDoc);
                 break;
-                
+
             case SYNC:
                 completeSync((DocumentWrapper<Object>) wrapDoc);
                 break;
-                
+
                        case WORKFLOW:
                                logger.error("Should never get to this code path.  If you did, there is a bug in the code.");
                                Thread.dumpStack();
                                break;
-                               
+
                        default:
                                logger.error("Should never get to this code path.  If you did, there is a bug in the code.");
                                Thread.dumpStack();
-                               break;                
+                               break;
         }
     }
 
@@ -394,13 +394,13 @@ public abstract class AbstractDocumentHandlerImpl<T, TL, WT, WTL>
     @Override
     public void completeDelete(DocumentWrapper<WT> wrapDoc) throws Exception {
     }
-    
+
     /* (non-Javadoc)
      * @see org.collectionspace.services.common.document.DocumentHandler#completeDelete(org.collectionspace.services.common.document.DocumentWrapper)
      */
     @Override
     public void completeSync(DocumentWrapper<Object> wrapDoc) throws Exception {
-    }    
+    }
 
     /* (non-Javadoc)
      * @see org.collectionspace.services.common.document.DocumentHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
@@ -461,7 +461,7 @@ public abstract class AbstractDocumentHandlerImpl<T, TL, WT, WTL>
     @Override
     public abstract String getQProperty(String prop) throws DocumentException;
 
-    /* 
+    /*
      * Strip Nuxeo's schema name from the start of the field / element name.
      * (non-Javadoc)
      * @see org.collectionspace.services.common.document.DocumentHandler#getUnQProperty(java.lang.String)
@@ -478,17 +478,22 @@ public abstract class AbstractDocumentHandlerImpl<T, TL, WT, WTL>
         tkz.nextToken(); //skip
         return tkz.nextToken();
     }
-    
+
     /**
      * Should return
-     * @throws Exception 
-     * @throws DocumentException 
+     * @throws Exception
+     * @throws DocumentException
      */
     @Override
     public String getDocumentsToIndexQuery(String indexId, String csid) throws DocumentException, Exception {
        return null;
     }
 
+    @Override
+    public String getDocumentsToIndexQuery(String indexId, String documentType, String csid) throws DocumentException, Exception {
+       return null;
+    }
+
     /* (non-Javadoc)
      * @see org.collectionspace.services.common.document.DocumentHandler#getServiceContextPath()
      */
@@ -509,11 +514,11 @@ public abstract class AbstractDocumentHandlerImpl<T, TL, WT, WTL>
             handler.validate(action, serviceContext);
         }
     }
-    
+
     /**
      * Creates the CMIS query from the service context.  Each document handler is responsible for returning a valid CMIS query using the
      * information in the current service context -which includes things like the query parameters, etc.
-     * @throws DocumentException 
+     * @throws DocumentException
      */
     @Override
     public String getCMISQuery(QueryContext queryContext) throws DocumentException {
@@ -522,20 +527,20 @@ public abstract class AbstractDocumentHandlerImpl<T, TL, WT, WTL>
        //
        return null;
     }
-    
+
     @Override
     public boolean isCMISQuery() {
        return false;
     }
-    
+
     @Override
     public boolean isJDBCQuery() {
        return false;
     }
-    
+
     @Override
     public Map<String,String> getJDBCQueryParams() {
         return new HashMap<>();
     }
-    
+
 }
index 731dff906caeb02091adb0d321146a7f23937ce7..970d4a2a7683ad19f35168af204b7ce14659dd19 100644 (file)
@@ -50,9 +50,9 @@ public interface DocumentHandler<T, TL, WT, WTL> {
     public enum Action {
         CREATE, GET, GET_ALL, UPDATE, DELETE, WORKFLOW, SYNC
     }
-    
+
     public Lifecycle getLifecycle();
-    
+
     public Lifecycle getLifecycle(String serviceObjectName);
 
     /**
@@ -75,7 +75,7 @@ public interface DocumentHandler<T, TL, WT, WTL> {
 
     /**
      * prepare is called by the client for preparation of stuff before
-     * invoking repository operation. this is mainly useful for create and 
+     * invoking repository operation. this is mainly useful for create and
      * update kind of actions
      * @param action
      * @throws Exception
@@ -86,7 +86,7 @@ public interface DocumentHandler<T, TL, WT, WTL> {
      * updateWorkflowTransition - prepare for a workflow transition
      */
     public void handleWorkflowTransition(ServiceContext ctx, DocumentWrapper<DocumentModel> wrapDoc, TransitionDef transitionDef) throws Exception;
-    
+
     /**
      * prepareCreate processes documents before creating document in repository
 
@@ -122,7 +122,7 @@ public interface DocumentHandler<T, TL, WT, WTL> {
 
     /**
      * prepare is called by the client to hand over the document processing task
-     * @param action 
+     * @param action
      * @param doc wrapped doc
      * @throws Exception
      */
@@ -236,7 +236,7 @@ public interface DocumentHandler<T, TL, WT, WTL> {
      * @throws Exception
      */
     public TL extractCommonPartList(DocumentWrapper<WTL> docWrap) throws Exception;
-    
+
 
     /**
      * Extract paging info.
@@ -246,7 +246,7 @@ public interface DocumentHandler<T, TL, WT, WTL> {
      * @return the tL
      * @throws Exception the exception
      */
-    public TL extractPagingInfo(TL theCommonList, DocumentWrapper<WTL> wrapDoc)        throws Exception;    
+    public TL extractPagingInfo(TL theCommonList, DocumentWrapper<WTL> wrapDoc)        throws Exception;
 
     /**
      * fillCommonPartList sets list common part of CS object into given document
@@ -275,7 +275,7 @@ public interface DocumentHandler<T, TL, WT, WTL> {
      * createDocumentFilter is a factory method to create a document
      * filter that is relevant to be used with this document handler
      * and corresponding storage client
-     * 
+     *
      * @return
      */
     public DocumentFilter createDocumentFilter();
@@ -323,7 +323,7 @@ public interface DocumentHandler<T, TL, WT, WTL> {
      * getQProperty get qualified property (useful for mapping to repository document property)
      * @param prop
      * @return
-     * @throws DocumentException 
+     * @throws DocumentException
      */
     public String getQProperty(String prop) throws DocumentException;
 
@@ -333,21 +333,28 @@ public interface DocumentHandler<T, TL, WT, WTL> {
      * @return unqualified property
      */
     public String getUnQProperty(String qProp);
-    
+
     /**
      * get a query string that will be used to return a set of documents that should be indexed/re-index
-     * @throws Exception 
-     * @throws DocumentException 
+     * @throws Exception
+     * @throws DocumentException
      */
     public String getDocumentsToIndexQuery(String indexId, String csid) throws DocumentException, Exception;
-    
+
+    /**
+     * get a query string that will be used to return a set of documents that should be indexed/re-index
+     * @throws Exception
+     * @throws DocumentException
+     */
+    public String getDocumentsToIndexQuery(String indexId, String documentType, String csid) throws DocumentException, Exception;
+
     /**
      * Creates the CMIS query from the service context.  Each document handler is responsible for returning a valid CMIS query using the
      * information in the current service context -which includes things like the query parameters, etc.
-     * @throws DocumentException 
+     * @throws DocumentException
      */
     public String getCMISQuery(QueryContext queryContext) throws DocumentException;
-    
+
     /**
      * Returns TRUE if a CMIS query should be used (instead of an NXQL query)
      */
@@ -357,29 +364,29 @@ public interface DocumentHandler<T, TL, WT, WTL> {
      * Returns TRUE if a JDBC/SQL query should be used (instead of an NXQL query)
      */
     public boolean isJDBCQuery();
-    
+
     /**
      * Returns parameter values, relevant to this document handler, that can be used in JDBC/SQL queries
-     * 
+     *
      * @return a set of zero or more parameter values relevant to this handler
      */
     public Map<String,String> getJDBCQueryParams();
 
     /**
-     * 
+     *
      * @throws Exception
      */
        void prepareSync() throws Exception;
 
        /**
-        * 
+        *
         * @param wrapDoc
         * @throws Exception
         */
        boolean handleSync(DocumentWrapper<Object> wrapDoc) throws Exception;
 
        /**
-        * 
+        *
         * @param wrapDoc
         * @throws Exception
         */
index 6c15294e68ae21ab7c4869d851771e265d866e5d..461ae716e152072921d6670a24e4ec329c7406b4 100644 (file)
@@ -64,6 +64,7 @@ import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl;
 import org.collectionspace.services.common.config.TenantBindingUtils;
 import org.collectionspace.services.common.storage.PreparedStatementBuilder;
 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthorityItemSpecifier;
+import org.collectionspace.services.config.service.ServiceBindingType;
 import org.collectionspace.services.config.tenant.TenantBindingType;
 import org.collectionspace.services.config.tenant.RepositoryDomainType;
 
@@ -91,6 +92,7 @@ import org.nuxeo.ecm.core.opencmis.impl.server.NuxeoCmisService;
 import org.nuxeo.elasticsearch.api.ElasticSearchAdmin;
 import org.nuxeo.elasticsearch.api.ElasticSearchIndexing;
 import org.nuxeo.elasticsearch.api.ElasticSearchService;
+import org.nuxeo.elasticsearch.ElasticSearchComponent;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -239,7 +241,7 @@ public class NuxeoRepositoryClientImpl implements RepositoryClient<PoxPayloadIn,
     public boolean reindex(DocumentHandler handler, String csid, String indexid) throws DocumentNotFoundException, DocumentException
     {
        boolean result = true;
-        
+
        switch (indexid) {
                case IndexClient.FULLTEXT_ID:
                        result = reindexFulltext(handler, csid, indexid);
@@ -254,10 +256,10 @@ public class NuxeoRepositoryClientImpl implements RepositoryClient<PoxPayloadIn,
 
        return result;
     }
-    
+
     /**
      * Reindex Nuxeo's fulltext index.
-     * 
+     *
      * @param handler
      * @param csid
      * @param indexid
@@ -289,10 +291,10 @@ public class NuxeoRepositoryClientImpl implements RepositoryClient<PoxPayloadIn,
 
        return result;
     }
-    
+
     /**
      * Reindex Nuxeo's Elasticsearch index.
-     * 
+     *
      * @param handler
      * @param csid
      * @param indexid
@@ -301,24 +303,43 @@ public class NuxeoRepositoryClientImpl implements RepositoryClient<PoxPayloadIn,
      * @throws TransactionException
      */
     private boolean reindexElasticsearch(DocumentHandler handler, String csid, String indexid) throws NuxeoDocumentException, TransactionException {
-       boolean result = false;
+        boolean result = false;
+
         if (!Framework.isBooleanPropertyTrue("elasticsearch.enabled")) {
-               logger.info("Request to reindex Elasticsearch failed because Elasticsearch is not enabled.");
-               return result;
+            throw new NuxeoDocumentException("Request to reindex Elasticsearch failed because Elasticsearch is not enabled.");
         }
-        
+
         CoreSessionInterface repoSession = null;
         ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = handler.getServiceContext();
 
         try {
-            ElasticSearchIndexing esi = Framework.getService(ElasticSearchIndexing.class);
-            ElasticSearchAdmin esa = Framework.getService(ElasticSearchAdmin.class);
-
-            String queryString = handler.getDocumentsToIndexQuery(indexid, csid);
-            esa.initIndexes(true);
-            esa.refresh();
             repoSession = getRepositorySession(ctx);
-            esi.runReindexingWorker(repoSession.getRepositoryName(), queryString);
+
+            ElasticSearchComponent es = (ElasticSearchComponent) Framework.getService(ElasticSearchService.class);
+            String repositoryName = repoSession.getRepositoryName();
+
+            logger.info(String.format("Rebuilding Elasticsearch index for repository %s", repositoryName));
+
+            es.dropAndInitRepositoryIndex(repositoryName);
+
+            TenantBindingConfigReaderImpl tReader = ServiceMain.getInstance().getTenantBindingConfigReader();
+            TenantBindingType tenantBinding = tReader.getTenantBinding(ctx.getTenantId());
+
+            for (ServiceBindingType serviceBinding : tenantBinding.getServiceBindings()) {
+                Boolean isElasticsearchIndexed = serviceBinding.isElasticsearchIndexed();
+                String servicesRepoDomainName = serviceBinding.getRepositoryDomain();
+
+                if (isElasticsearchIndexed && servicesRepoDomainName != null && servicesRepoDomainName.trim().isEmpty() == false) {
+                    String docType = NuxeoUtils.getTenantQualifiedDocType(tenantBinding.getId(), serviceBinding.getObject().getName());
+                    String queryString = handler.getDocumentsToIndexQuery(indexid, docType, csid);
+
+                    logger.info(String.format("Starting Elasticsearch reindexing for docType %s in repository %s", docType, repositoryName));
+                    logger.debug(queryString);
+
+                    es.runReindexingWorker(repositoryName, queryString);
+                }
+            }
+
             result = true;
         } catch (Throwable e) {
                rollbackTransaction(repoSession);
@@ -331,7 +352,7 @@ public class NuxeoRepositoryClientImpl implements RepositoryClient<PoxPayloadIn,
                 releaseRepositorySession(ctx, repoSession);
             }
         }
-        
+
         return result;
     }
 
index dd06e39bb9a892ad293364f261c3f86e8a25ff5f..020398a92eeeebef36c09692cb8910830ccc4722 100644 (file)
@@ -50,21 +50,25 @@ public class IndexDocumentModelHandler
         extends NuxeoDocumentModelHandler<IndexCommon> {
        private final Logger logger = LoggerFactory.getLogger(IndexDocumentModelHandler.class);
 
-       
        @Override
-    public String getDocumentsToIndexQuery(String indexId, String csid) throws DocumentException, Exception {
+       public String getDocumentsToIndexQuery(String indexId, String csid) throws DocumentException, Exception {
+               return getDocumentsToIndexQuery(indexId, "Document", csid);
+       }
+
+       @Override
+    public String getDocumentsToIndexQuery(String indexId, String documentType, String csid) throws DocumentException, Exception {
                String result = null;
-               
+
        switch (indexId) {
                case IndexClient.FULLTEXT_ID:
-                       result = getReindexQuery(indexId, csid);
+                       result = getReindexQuery(indexId, documentType, csid);
                        break;
                case IndexClient.ELASTICSEARCH_ID:
-                       result = getReindexQuery(indexId, csid);
-                       
+                       result = getReindexQuery(indexId, documentType, csid);
+
                        break;
        }
-       
+
        if (Tools.isEmpty(result) == true) {
                String msg = String.format("There is no reindex query in the Index service bindings for index '%s', so we'll use this default query: '%s'",
                                indexId, IndexClient.DEFAULT_REINDEX_QUERY);
@@ -74,41 +78,42 @@ public class IndexDocumentModelHandler
 
        return result;
     }
-       
+
        /**
         * Reads the Index service bindings to get the query that will be used to find all documents needing
         * reindexing.
-        * 
+        *
         * @param indexId
+        * @param documentType
         * @param csid
         * @return
         * @throws DocumentException
         * @throws Exception
-        * 
+        *
         * TODO: Use the incoming CSID param to qualify the returned query.
         */
-       private String getReindexQuery(String indexId, String csid) throws DocumentException, Exception {
+       private String getReindexQuery(String indexId, String documentType, String csid) throws DocumentException, Exception {
                String result = null;
-               
-       //
-       // Read in the NXQL query to use when performing a full 
-       //
-        TenantBindingConfigReaderImpl tReader =
-                ServiceMain.getInstance().getTenantBindingConfigReader();
-        ServiceContext ctx = this.getServiceContext();
-        
-        ServiceBindingType reportServiceBinding = tReader.getServiceBinding(ctx.getTenantId(), ctx.getServiceName());
-        List<PropertyItemType> queryTypeList = ServiceBindingUtils.getPropertyValueList(reportServiceBinding, indexId);
-        
-        if (queryTypeList != null && queryTypeList.isEmpty() == false) {
-               PropertyItemType propertyItemType = queryTypeList.get(0);
-               if (propertyItemType != null) {
-                       result = propertyItemType.getValue();
-               }
-        }
-        
-        return result;
-    }
 
-}
+               //
+               // Read in the NXQL query to use when performing a full
+               //
+               TenantBindingConfigReaderImpl tReader = ServiceMain.getInstance().getTenantBindingConfigReader();
+               ServiceContext ctx = this.getServiceContext();
+
+               ServiceBindingType serviceBinding = tReader.getServiceBinding(ctx.getTenantId(), ctx.getServiceName());
+               List<PropertyItemType> queryTypeList = ServiceBindingUtils.getPropertyValueList(serviceBinding, indexId);
+
+               if (queryTypeList != null && queryTypeList.isEmpty() == false) {
+                       PropertyItemType propertyItemType = queryTypeList.get(0);
+                       if (propertyItemType != null) {
+                               String query = propertyItemType.getValue();
 
+                               result = String.format(query, documentType);
+                       }
+               }
+
+               return result;
+       }
+
+}