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));
}
}
}
</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">
*
* $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>
/** 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;
}
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()
*/
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();
@Override
final public boolean handle(Action action, DocumentWrapper<?> wrapDoc) throws Exception {
boolean result = true;
-
+
switch (action) {
case CREATE:
handleCreate((DocumentWrapper<WT>) wrapDoc);
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) {
//
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)
*/
// 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)
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;
}
}
@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)
@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)
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()
*/
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 {
//
return null;
}
-
+
@Override
public boolean isCMISQuery() {
return false;
}
-
+
@Override
public boolean isJDBCQuery() {
return false;
}
-
+
@Override
public Map<String,String> getJDBCQueryParams() {
return new HashMap<>();
}
-
+
}
public enum Action {
CREATE, GET, GET_ALL, UPDATE, DELETE, WORKFLOW, SYNC
}
-
+
public Lifecycle getLifecycle();
-
+
public Lifecycle getLifecycle(String serviceObjectName);
/**
/**
* 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
* 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
/**
* prepare is called by the client to hand over the document processing task
- * @param action
+ * @param action
* @param doc wrapped doc
* @throws Exception
*/
* @throws Exception
*/
public TL extractCommonPartList(DocumentWrapper<WTL> docWrap) throws Exception;
-
+
/**
* Extract paging info.
* @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
* 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();
* 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;
* @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)
*/
* 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
*/
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;
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;
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);
return result;
}
-
+
/**
* Reindex Nuxeo's fulltext index.
- *
+ *
* @param handler
* @param csid
* @param indexid
return result;
}
-
+
/**
* Reindex Nuxeo's Elasticsearch index.
- *
+ *
* @param handler
* @param csid
* @param indexid
* @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);
releaseRepositorySession(ctx, repoSession);
}
}
-
+
return result;
}
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);
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;
+ }
+
+}