mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-16 17:55:15 +00:00
- add TenantService hooks to ADM Searcher & Indexer
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6401 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
65f660c26c
commit
dbdbb003f1
@ -347,6 +347,9 @@
|
|||||||
<property name="nodeService">
|
<property name="nodeService">
|
||||||
<ref bean="mlAwareNodeService" />
|
<ref bean="mlAwareNodeService" />
|
||||||
</property>
|
</property>
|
||||||
|
<property name="tenantService">
|
||||||
|
<ref bean="tenantService"/>
|
||||||
|
</property>
|
||||||
<property name="dictionaryService">
|
<property name="dictionaryService">
|
||||||
<ref bean="dictionaryService" />
|
<ref bean="dictionaryService" />
|
||||||
</property>
|
</property>
|
||||||
@ -464,6 +467,9 @@
|
|||||||
<property name="nodeService">
|
<property name="nodeService">
|
||||||
<ref bean="nodeService" />
|
<ref bean="nodeService" />
|
||||||
</property>
|
</property>
|
||||||
|
<property name="tenantService">
|
||||||
|
<ref bean="tenantService"/>
|
||||||
|
</property>
|
||||||
<property name="dictionaryService">
|
<property name="dictionaryService">
|
||||||
<ref bean="dictionaryService" />
|
<ref bean="dictionaryService" />
|
||||||
</property>
|
</property>
|
||||||
|
@ -96,8 +96,11 @@ public class ADMLuceneIndexerAndSearcherFactory extends AbstractLuceneIndexerAnd
|
|||||||
|
|
||||||
protected LuceneIndexer createIndexer(StoreRef storeRef, String deltaId)
|
protected LuceneIndexer createIndexer(StoreRef storeRef, String deltaId)
|
||||||
{
|
{
|
||||||
|
storeRef = tenantService.getName(storeRef);
|
||||||
|
|
||||||
ADMLuceneIndexerImpl indexer = ADMLuceneIndexerImpl.getUpdateIndexer(storeRef, deltaId, this);
|
ADMLuceneIndexerImpl indexer = ADMLuceneIndexerImpl.getUpdateIndexer(storeRef, deltaId, this);
|
||||||
indexer.setNodeService(nodeService);
|
indexer.setNodeService(nodeService);
|
||||||
|
indexer.setTenantService(tenantService);
|
||||||
indexer.setDictionaryService(dictionaryService);
|
indexer.setDictionaryService(dictionaryService);
|
||||||
// indexer.setLuceneIndexLock(luceneIndexLock);
|
// indexer.setLuceneIndexLock(luceneIndexLock);
|
||||||
indexer.setFullTextSearchIndexer(fullTextSearchIndexer);
|
indexer.setFullTextSearchIndexer(fullTextSearchIndexer);
|
||||||
@ -108,10 +111,13 @@ public class ADMLuceneIndexerAndSearcherFactory extends AbstractLuceneIndexerAnd
|
|||||||
|
|
||||||
protected LuceneSearcher getSearcher(StoreRef storeRef, LuceneIndexer indexer) throws SearcherException
|
protected LuceneSearcher getSearcher(StoreRef storeRef, LuceneIndexer indexer) throws SearcherException
|
||||||
{
|
{
|
||||||
|
storeRef = tenantService.getName(storeRef);
|
||||||
|
|
||||||
ADMLuceneSearcherImpl searcher = ADMLuceneSearcherImpl.getSearcher(storeRef, indexer, this);
|
ADMLuceneSearcherImpl searcher = ADMLuceneSearcherImpl.getSearcher(storeRef, indexer, this);
|
||||||
searcher.setNamespacePrefixResolver(nameSpaceService);
|
searcher.setNamespacePrefixResolver(nameSpaceService);
|
||||||
// searcher.setLuceneIndexLock(luceneIndexLock);
|
// searcher.setLuceneIndexLock(luceneIndexLock);
|
||||||
searcher.setNodeService(nodeService);
|
searcher.setNodeService(nodeService);
|
||||||
|
searcher.setTenantService(tenantService);
|
||||||
searcher.setDictionaryService(dictionaryService);
|
searcher.setDictionaryService(dictionaryService);
|
||||||
searcher.setQueryRegister(getQueryRegister());
|
searcher.setQueryRegister(getQueryRegister());
|
||||||
return searcher;
|
return searcher;
|
||||||
|
@ -48,6 +48,7 @@ import org.alfresco.repo.content.transform.ContentTransformer;
|
|||||||
import org.alfresco.repo.search.IndexerException;
|
import org.alfresco.repo.search.IndexerException;
|
||||||
import org.alfresco.repo.search.impl.lucene.fts.FTSIndexerAware;
|
import org.alfresco.repo.search.impl.lucene.fts.FTSIndexerAware;
|
||||||
import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer;
|
import org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexer;
|
||||||
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
@ -98,6 +99,11 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
|
|||||||
*/
|
*/
|
||||||
NodeService nodeService;
|
NodeService nodeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The tenant service we use for multi-tenancy
|
||||||
|
*/
|
||||||
|
TenantService tenantService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content service to get content for indexing.
|
* Content service to get content for indexing.
|
||||||
*/
|
*/
|
||||||
@ -127,25 +133,35 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IOC setting of dictionary service
|
* IOC setting of the dictionary service
|
||||||
|
*
|
||||||
|
* @param dictionaryService
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setDictionaryService(DictionaryService dictionaryService)
|
public void setDictionaryService(DictionaryService dictionaryService)
|
||||||
{
|
{
|
||||||
super.setDictionaryService(dictionaryService);
|
super.setDictionaryService(dictionaryService);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setter for getting the node service via IOC Used in the Spring container
|
* IOC setting of the node service
|
||||||
*
|
*
|
||||||
* @param nodeService
|
* @param nodeService
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void setNodeService(NodeService nodeService)
|
public void setNodeService(NodeService nodeService)
|
||||||
{
|
{
|
||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IOC setting of the tenant service
|
||||||
|
*
|
||||||
|
* @param tenantService
|
||||||
|
*/
|
||||||
|
public void setTenantService(TenantService tenantService)
|
||||||
|
{
|
||||||
|
this.tenantService = tenantService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IOC setting of the content service
|
* IOC setting of the content service
|
||||||
*
|
*
|
||||||
@ -171,7 +187,8 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
|
|||||||
{
|
{
|
||||||
NodeRef childRef = relationshipRef.getChildRef();
|
NodeRef childRef = relationshipRef.getChildRef();
|
||||||
// If we have the root node we delete all other root nodes first
|
// If we have the root node we delete all other root nodes first
|
||||||
if ((relationshipRef.getParentRef() == null) && childRef.equals(nodeService.getRootNode(childRef.getStoreRef())))
|
if ((relationshipRef.getParentRef() == null)
|
||||||
|
&& tenantService.getBaseName(childRef).equals(nodeService.getRootNode(childRef.getStoreRef())))
|
||||||
{
|
{
|
||||||
addRootNodesToDeletionList();
|
addRootNodesToDeletionList();
|
||||||
s_logger.warn("Detected root node addition: deleting all nodes from the index");
|
s_logger.warn("Detected root node addition: deleting all nodes from the index");
|
||||||
@ -226,6 +243,8 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
|
|||||||
|
|
||||||
public void updateNode(NodeRef nodeRef) throws LuceneIndexException
|
public void updateNode(NodeRef nodeRef) throws LuceneIndexException
|
||||||
{
|
{
|
||||||
|
nodeRef = tenantService.getName(nodeRef);
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled())
|
if (s_logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
s_logger.debug("Update node " + nodeRef);
|
s_logger.debug("Update node " + nodeRef);
|
||||||
@ -547,7 +566,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isRoot = nodeRef.equals(nodeService.getRootNode(nodeRef.getStoreRef()));
|
boolean isRoot = nodeRef.equals(tenantService.getName(nodeService.getRootNode(nodeRef.getStoreRef())));
|
||||||
|
|
||||||
StringBuilder qNameBuffer = new StringBuilder(64);
|
StringBuilder qNameBuffer = new StringBuilder(64);
|
||||||
|
|
||||||
@ -588,7 +607,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
|
|||||||
qNameBuffer.append(";/");
|
qNameBuffer.append(";/");
|
||||||
}
|
}
|
||||||
qNameBuffer.append(ISO9075.getXPathName(qNameRef.getQName()));
|
qNameBuffer.append(ISO9075.getXPathName(qNameRef.getQName()));
|
||||||
xdoc.add(new Field("PARENT", qNameRef.getParentRef().toString(), Field.Store.YES, Field.Index.UN_TOKENIZED, Field.TermVector.NO));
|
xdoc.add(new Field("PARENT", tenantService.getName(qNameRef.getParentRef()).toString(), Field.Store.YES, Field.Index.UN_TOKENIZED, Field.TermVector.NO));
|
||||||
xdoc.add(new Field("ASSOCTYPEQNAME", ISO9075.getXPathName(qNameRef.getTypeQName()), Field.Store.YES, Field.Index.NO, Field.TermVector.NO));
|
xdoc.add(new Field("ASSOCTYPEQNAME", ISO9075.getXPathName(qNameRef.getTypeQName()), Field.Store.YES, Field.Index.NO, Field.TermVector.NO));
|
||||||
xdoc.add(new Field("LINKASPECT", (pair.getSecond() == null) ? "" : ISO9075.getXPathName(pair.getSecond()), Field.Store.YES, Field.Index.UN_TOKENIZED,
|
xdoc.add(new Field("LINKASPECT", (pair.getSecond() == null) ? "" : ISO9075.getXPathName(pair.getSecond()), Field.Store.YES, Field.Index.UN_TOKENIZED,
|
||||||
Field.TermVector.NO));
|
Field.TermVector.NO));
|
||||||
@ -613,7 +632,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
|
|||||||
directoryEntry.add(new Field("PATH", pathString, Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.NO));
|
directoryEntry.add(new Field("PATH", pathString, Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.NO));
|
||||||
for (NodeRef parent : getParents(pair.getFirst()))
|
for (NodeRef parent : getParents(pair.getFirst()))
|
||||||
{
|
{
|
||||||
directoryEntry.add(new Field("ANCESTOR", parent.toString(), Field.Store.NO, Field.Index.UN_TOKENIZED, Field.TermVector.NO));
|
directoryEntry.add(new Field("ANCESTOR", tenantService.getName(parent).toString(), Field.Store.NO, Field.Index.UN_TOKENIZED, Field.TermVector.NO));
|
||||||
}
|
}
|
||||||
directoryEntry.add(new Field("ISCONTAINER", "T", Field.Store.YES, Field.Index.UN_TOKENIZED, Field.TermVector.NO));
|
directoryEntry.add(new Field("ISCONTAINER", "T", Field.Store.YES, Field.Index.UN_TOKENIZED, Field.TermVector.NO));
|
||||||
|
|
||||||
@ -650,7 +669,7 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
|
|||||||
// true));
|
// true));
|
||||||
|
|
||||||
ChildAssociationRef primary = nodeService.getPrimaryParent(nodeRef);
|
ChildAssociationRef primary = nodeService.getPrimaryParent(nodeRef);
|
||||||
xdoc.add(new Field("PRIMARYPARENT", primary.getParentRef().toString(), Field.Store.YES, Field.Index.UN_TOKENIZED, Field.TermVector.NO));
|
xdoc.add(new Field("PRIMARYPARENT", tenantService.getName(primary.getParentRef()).toString(), Field.Store.YES, Field.Index.UN_TOKENIZED, Field.TermVector.NO));
|
||||||
xdoc.add(new Field("PRIMARYASSOCTYPEQNAME", ISO9075.getXPathName(primary.getTypeQName()), Field.Store.YES, Field.Index.NO, Field.TermVector.NO));
|
xdoc.add(new Field("PRIMARYASSOCTYPEQNAME", ISO9075.getXPathName(primary.getTypeQName()), Field.Store.YES, Field.Index.NO, Field.TermVector.NO));
|
||||||
QName typeQName = nodeService.getType(nodeRef);
|
QName typeQName = nodeService.getType(nodeRef);
|
||||||
|
|
||||||
@ -1061,6 +1080,9 @@ public class ADMLuceneIndexerImpl extends AbstractLuceneIndexerImpl<NodeRef> imp
|
|||||||
{
|
{
|
||||||
if (catRef != null)
|
if (catRef != null)
|
||||||
{
|
{
|
||||||
|
// can be running in context of System user, hence use input nodeRef
|
||||||
|
catRef = tenantService.getName(nodeRef, catRef);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (Path path : nodeService.getPaths(catRef, false))
|
for (Path path : nodeService.getPaths(catRef, false))
|
||||||
|
@ -40,6 +40,7 @@ import org.alfresco.repo.search.QueryRegisterComponent;
|
|||||||
import org.alfresco.repo.search.SearcherException;
|
import org.alfresco.repo.search.SearcherException;
|
||||||
import org.alfresco.repo.search.impl.NodeSearcher;
|
import org.alfresco.repo.search.impl.NodeSearcher;
|
||||||
import org.alfresco.repo.search.impl.lucene.QueryParser.Operator;
|
import org.alfresco.repo.search.impl.lucene.QueryParser.Operator;
|
||||||
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@ -86,6 +87,8 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
|||||||
|
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
|
||||||
|
private TenantService tenantService;
|
||||||
|
|
||||||
private DictionaryService dictionaryService;
|
private DictionaryService dictionaryService;
|
||||||
|
|
||||||
private QueryRegisterComponent queryRegister;
|
private QueryRegisterComponent queryRegister;
|
||||||
@ -148,6 +151,11 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
|||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTenantService(TenantService tenantService)
|
||||||
|
{
|
||||||
|
this.tenantService = tenantService;
|
||||||
|
}
|
||||||
|
|
||||||
public void setDictionaryService(DictionaryService dictionaryService)
|
public void setDictionaryService(DictionaryService dictionaryService)
|
||||||
{
|
{
|
||||||
this.dictionaryService = dictionaryService;
|
this.dictionaryService = dictionaryService;
|
||||||
@ -165,6 +173,8 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
|||||||
public ResultSet query(StoreRef store, String language, String queryString, Path[] queryOptions,
|
public ResultSet query(StoreRef store, String language, String queryString, Path[] queryOptions,
|
||||||
QueryParameterDefinition[] queryParameterDefinitions) throws SearcherException
|
QueryParameterDefinition[] queryParameterDefinitions) throws SearcherException
|
||||||
{
|
{
|
||||||
|
store = tenantService.getName(store);
|
||||||
|
|
||||||
SearchParameters sp = new SearchParameters();
|
SearchParameters sp = new SearchParameters();
|
||||||
sp.addStore(store);
|
sp.addStore(store);
|
||||||
sp.setLanguage(language);
|
sp.setLanguage(language);
|
||||||
@ -195,6 +205,9 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
|||||||
throw new IllegalStateException("Only one store can be searched at present");
|
throw new IllegalStateException("Only one store can be searched at present");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArrayList<StoreRef> stores = searchParameters.getStores();
|
||||||
|
stores.set(0, tenantService.getName(searchParameters.getStores().get(0)));
|
||||||
|
|
||||||
String parameterisedQueryString;
|
String parameterisedQueryString;
|
||||||
if (searchParameters.getQueryParameterDefinitions().size() > 0)
|
if (searchParameters.getQueryParameterDefinitions().size() > 0)
|
||||||
{
|
{
|
||||||
@ -227,8 +240,10 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
|||||||
defaultOperator = LuceneQueryParser.OR_OPERATOR;
|
defaultOperator = LuceneQueryParser.OR_OPERATOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
Query query = LuceneQueryParser.parse(parameterisedQueryString, DEFAULT_FIELD, new LuceneAnalyser(
|
Query query = LuceneQueryParser.parse(parameterisedQueryString, DEFAULT_FIELD,
|
||||||
dictionaryService, searchParameters.getMlAnalaysisMode() == null ? getLuceneConfig().getDefaultMLSearchAnalysisMode() : searchParameters.getMlAnalaysisMode()), namespacePrefixResolver, dictionaryService, defaultOperator, searchParameters, getLuceneConfig());
|
new LuceneAnalyser(dictionaryService, searchParameters.getMlAnalaysisMode() == null ? getLuceneConfig().getDefaultMLSearchAnalysisMode() : searchParameters.getMlAnalaysisMode()),
|
||||||
|
namespacePrefixResolver, dictionaryService, tenantService, defaultOperator, searchParameters, getLuceneConfig());
|
||||||
|
|
||||||
ClosingIndexSearcher searcher = getSearcher(indexer);
|
ClosingIndexSearcher searcher = getSearcher(indexer);
|
||||||
if (searcher == null)
|
if (searcher == null)
|
||||||
{
|
{
|
||||||
@ -277,6 +292,7 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
|||||||
hits,
|
hits,
|
||||||
searcher,
|
searcher,
|
||||||
nodeService,
|
nodeService,
|
||||||
|
tenantService,
|
||||||
paths,
|
paths,
|
||||||
searchParameters);
|
searchParameters);
|
||||||
|
|
||||||
@ -312,7 +328,7 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
|||||||
return new EmptyResultSet();
|
return new EmptyResultSet();
|
||||||
}
|
}
|
||||||
Hits hits = searcher.search(query);
|
Hits hits = searcher.search(query);
|
||||||
return new LuceneResultSet(hits, searcher, nodeService, searchParameters.getAttributePaths().toArray(
|
return new LuceneResultSet(hits, searcher, nodeService, tenantService, searchParameters.getAttributePaths().toArray(
|
||||||
new Path[0]), searchParameters);
|
new Path[0]), searchParameters);
|
||||||
}
|
}
|
||||||
catch (SAXPathException e)
|
catch (SAXPathException e)
|
||||||
@ -536,6 +552,9 @@ public class ADMLuceneSearcherImpl extends AbstractLuceneBase implements LuceneS
|
|||||||
throws InvalidNodeRefException, XPathException
|
throws InvalidNodeRefException, XPathException
|
||||||
{
|
{
|
||||||
NodeSearcher nodeSearcher = new NodeSearcher(nodeService, dictionaryService, this);
|
NodeSearcher nodeSearcher = new NodeSearcher(nodeService, dictionaryService, this);
|
||||||
|
|
||||||
|
contextNodeRef = tenantService.getName(contextNodeRef);
|
||||||
|
|
||||||
return nodeSearcher.selectNodes(contextNodeRef, xpath, parameters, namespacePrefixResolver,
|
return nodeSearcher.selectNodes(contextNodeRef, xpath, parameters, namespacePrefixResolver,
|
||||||
followAllParentLinks, language);
|
followAllParentLinks, language);
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@ import org.alfresco.repo.search.SearcherException;
|
|||||||
import org.alfresco.repo.search.impl.lucene.index.IndexInfo;
|
import org.alfresco.repo.search.impl.lucene.index.IndexInfo;
|
||||||
import org.alfresco.repo.search.transaction.SimpleTransaction;
|
import org.alfresco.repo.search.transaction.SimpleTransaction;
|
||||||
import org.alfresco.repo.search.transaction.SimpleTransactionManager;
|
import org.alfresco.repo.search.transaction.SimpleTransactionManager;
|
||||||
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
@ -106,9 +107,7 @@ public abstract class AbstractLuceneIndexerAndSearcherFactory implements LuceneI
|
|||||||
*/
|
*/
|
||||||
private static final int DEFAULT_TIMEOUT = 600000;
|
private static final int DEFAULT_TIMEOUT = 600000;
|
||||||
|
|
||||||
/**
|
protected TenantService tenantService;
|
||||||
* The node service we use to get information about nodes
|
|
||||||
*/
|
|
||||||
|
|
||||||
private String indexRootLocation;
|
private String indexRootLocation;
|
||||||
|
|
||||||
@ -149,6 +148,16 @@ public abstract class AbstractLuceneIndexerAndSearcherFactory implements LuceneI
|
|||||||
this.indexRootLocation = indexRootLocation;
|
this.indexRootLocation = indexRootLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tenant service
|
||||||
|
*
|
||||||
|
* @param tenantService
|
||||||
|
*/
|
||||||
|
public void setTenantService(TenantService tenantService)
|
||||||
|
{
|
||||||
|
this.tenantService = tenantService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the query register
|
* Set the query register
|
||||||
*
|
*
|
||||||
@ -235,6 +244,8 @@ public abstract class AbstractLuceneIndexerAndSearcherFactory implements LuceneI
|
|||||||
*/
|
*/
|
||||||
public LuceneIndexer getIndexer(StoreRef storeRef) throws IndexerException
|
public LuceneIndexer getIndexer(StoreRef storeRef) throws IndexerException
|
||||||
{
|
{
|
||||||
|
storeRef = tenantService.getName(storeRef);
|
||||||
|
|
||||||
// register to receive txn callbacks
|
// register to receive txn callbacks
|
||||||
// TODO: make this conditional on whether the XA stuff is being used
|
// TODO: make this conditional on whether the XA stuff is being used
|
||||||
// directly on not
|
// directly on not
|
||||||
@ -346,6 +357,8 @@ public abstract class AbstractLuceneIndexerAndSearcherFactory implements LuceneI
|
|||||||
*/
|
*/
|
||||||
public LuceneSearcher getSearcher(StoreRef storeRef, boolean searchDelta) throws SearcherException
|
public LuceneSearcher getSearcher(StoreRef storeRef, boolean searchDelta) throws SearcherException
|
||||||
{
|
{
|
||||||
|
storeRef = tenantService.getName(storeRef);
|
||||||
|
|
||||||
String deltaId = null;
|
String deltaId = null;
|
||||||
LuceneIndexer indexer = null;
|
LuceneIndexer indexer = null;
|
||||||
if (searchDelta)
|
if (searchDelta)
|
||||||
|
@ -37,6 +37,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
|||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.search.IndexerAndSearcher;
|
import org.alfresco.repo.search.IndexerAndSearcher;
|
||||||
import org.alfresco.repo.search.IndexerException;
|
import org.alfresco.repo.search.IndexerException;
|
||||||
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@ -60,6 +61,8 @@ public class LuceneCategoryServiceImpl implements CategoryService
|
|||||||
{
|
{
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
|
||||||
|
private TenantService tenantService;
|
||||||
|
|
||||||
private NamespacePrefixResolver namespacePrefixResolver;
|
private NamespacePrefixResolver namespacePrefixResolver;
|
||||||
|
|
||||||
private DictionaryService dictionaryService;
|
private DictionaryService dictionaryService;
|
||||||
@ -85,6 +88,15 @@ public class LuceneCategoryServiceImpl implements CategoryService
|
|||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tenant service
|
||||||
|
* @param tenantService
|
||||||
|
*/
|
||||||
|
public void setTenantService(TenantService tenantService)
|
||||||
|
{
|
||||||
|
this.tenantService = tenantService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the service to map prefixes to uris
|
* Set the service to map prefixes to uris
|
||||||
* @param namespacePrefixResolver
|
* @param namespacePrefixResolver
|
||||||
@ -118,6 +130,9 @@ public class LuceneCategoryServiceImpl implements CategoryService
|
|||||||
{
|
{
|
||||||
return Collections.<ChildAssociationRef> emptyList();
|
return Collections.<ChildAssociationRef> emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
categoryRef = tenantService.getName(categoryRef);
|
||||||
|
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -244,6 +259,8 @@ public class LuceneCategoryServiceImpl implements CategoryService
|
|||||||
|
|
||||||
private Set<NodeRef> getClassificationNodes(StoreRef storeRef, QName qname)
|
private Set<NodeRef> getClassificationNodes(StoreRef storeRef, QName qname)
|
||||||
{
|
{
|
||||||
|
storeRef = tenantService.getName(storeRef);
|
||||||
|
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -269,6 +286,8 @@ public class LuceneCategoryServiceImpl implements CategoryService
|
|||||||
|
|
||||||
public Collection<ChildAssociationRef> getClassifications(StoreRef storeRef)
|
public Collection<ChildAssociationRef> getClassifications(StoreRef storeRef)
|
||||||
{
|
{
|
||||||
|
storeRef = tenantService.getName(storeRef);
|
||||||
|
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -40,11 +40,14 @@ import org.alfresco.repo.search.SearcherException;
|
|||||||
import org.alfresco.repo.search.impl.lucene.analysis.MLTokenDuplicator;
|
import org.alfresco.repo.search.impl.lucene.analysis.MLTokenDuplicator;
|
||||||
import org.alfresco.repo.search.impl.lucene.analysis.VerbatimAnalyser;
|
import org.alfresco.repo.search.impl.lucene.analysis.VerbatimAnalyser;
|
||||||
import org.alfresco.repo.search.impl.lucene.query.PathQuery;
|
import org.alfresco.repo.search.impl.lucene.query.PathQuery;
|
||||||
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
import org.alfresco.service.cmr.dictionary.TypeDefinition;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.StoreRef;
|
||||||
import org.alfresco.service.cmr.search.SearchParameters;
|
import org.alfresco.service.cmr.search.SearchParameters;
|
||||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
@ -70,6 +73,8 @@ public class LuceneQueryParser extends QueryParser
|
|||||||
|
|
||||||
private DictionaryService dictionaryService;
|
private DictionaryService dictionaryService;
|
||||||
|
|
||||||
|
private TenantService tenantService;
|
||||||
|
|
||||||
private SearchParameters searchParameters;
|
private SearchParameters searchParameters;
|
||||||
|
|
||||||
private LuceneConfig config;
|
private LuceneConfig config;
|
||||||
@ -88,7 +93,7 @@ public class LuceneQueryParser extends QueryParser
|
|||||||
* if the parsing fails
|
* if the parsing fails
|
||||||
*/
|
*/
|
||||||
static public Query parse(String query, String field, Analyzer analyzer,
|
static public Query parse(String query, String field, Analyzer analyzer,
|
||||||
NamespacePrefixResolver namespacePrefixResolver, DictionaryService dictionaryService,
|
NamespacePrefixResolver namespacePrefixResolver, DictionaryService dictionaryService, TenantService tenantService,
|
||||||
Operator defaultOperator, SearchParameters searchParameters, LuceneConfig config) throws ParseException
|
Operator defaultOperator, SearchParameters searchParameters, LuceneConfig config) throws ParseException
|
||||||
{
|
{
|
||||||
if (s_logger.isDebugEnabled())
|
if (s_logger.isDebugEnabled())
|
||||||
@ -99,6 +104,7 @@ public class LuceneQueryParser extends QueryParser
|
|||||||
parser.setDefaultOperator(defaultOperator);
|
parser.setDefaultOperator(defaultOperator);
|
||||||
parser.setNamespacePrefixResolver(namespacePrefixResolver);
|
parser.setNamespacePrefixResolver(namespacePrefixResolver);
|
||||||
parser.setDictionaryService(dictionaryService);
|
parser.setDictionaryService(dictionaryService);
|
||||||
|
parser.setTenantService(tenantService);
|
||||||
parser.setSearchParameters(searchParameters);
|
parser.setSearchParameters(searchParameters);
|
||||||
parser.setLuceneConfig(config);
|
parser.setLuceneConfig(config);
|
||||||
// TODO: Apply locale contstraints at the top level if required for the non ML doc types.
|
// TODO: Apply locale contstraints at the top level if required for the non ML doc types.
|
||||||
@ -125,6 +131,11 @@ public class LuceneQueryParser extends QueryParser
|
|||||||
this.namespacePrefixResolver = namespacePrefixResolver;
|
this.namespacePrefixResolver = namespacePrefixResolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTenantService(TenantService tenantService)
|
||||||
|
{
|
||||||
|
this.tenantService = tenantService;
|
||||||
|
}
|
||||||
|
|
||||||
public LuceneQueryParser(String arg0, Analyzer arg1)
|
public LuceneQueryParser(String arg0, Analyzer arg1)
|
||||||
{
|
{
|
||||||
super(arg0, arg1);
|
super(arg0, arg1);
|
||||||
@ -212,6 +223,11 @@ public class LuceneQueryParser extends QueryParser
|
|||||||
}
|
}
|
||||||
else if (field.equals("ID"))
|
else if (field.equals("ID"))
|
||||||
{
|
{
|
||||||
|
if (tenantService.isTenantUser() && (queryText.contains(StoreRef.URI_FILLER)))
|
||||||
|
{
|
||||||
|
// assume NodeRef, since it contains StorRef URI filler
|
||||||
|
queryText = tenantService.getName(new NodeRef(queryText)).toString();
|
||||||
|
}
|
||||||
TermQuery termQuery = new TermQuery(new Term(field, queryText));
|
TermQuery termQuery = new TermQuery(new Term(field, queryText));
|
||||||
return termQuery;
|
return termQuery;
|
||||||
}
|
}
|
||||||
@ -237,11 +253,21 @@ public class LuceneQueryParser extends QueryParser
|
|||||||
}
|
}
|
||||||
else if (field.equals("PARENT"))
|
else if (field.equals("PARENT"))
|
||||||
{
|
{
|
||||||
|
if (tenantService.isTenantUser() && (queryText.contains(StoreRef.URI_FILLER)))
|
||||||
|
{
|
||||||
|
// assume NodeRef, since it contains StoreRef URI filler
|
||||||
|
queryText = tenantService.getName(new NodeRef(queryText)).toString();
|
||||||
|
}
|
||||||
TermQuery termQuery = new TermQuery(new Term(field, queryText));
|
TermQuery termQuery = new TermQuery(new Term(field, queryText));
|
||||||
return termQuery;
|
return termQuery;
|
||||||
}
|
}
|
||||||
else if (field.equals("PRIMARYPARENT"))
|
else if (field.equals("PRIMARYPARENT"))
|
||||||
{
|
{
|
||||||
|
if (tenantService.isTenantUser() && (queryText.contains(StoreRef.URI_FILLER)))
|
||||||
|
{
|
||||||
|
// assume NodeRef, since it contains StoreRef URI filler
|
||||||
|
queryText = tenantService.getName(new NodeRef(queryText)).toString();
|
||||||
|
}
|
||||||
TermQuery termQuery = new TermQuery(new Term(field, queryText));
|
TermQuery termQuery = new TermQuery(new Term(field, queryText));
|
||||||
return termQuery;
|
return termQuery;
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ import org.alfresco.repo.search.AbstractResultSet;
|
|||||||
import org.alfresco.repo.search.ResultSetRowIterator;
|
import org.alfresco.repo.search.ResultSetRowIterator;
|
||||||
import org.alfresco.repo.search.SearcherException;
|
import org.alfresco.repo.search.SearcherException;
|
||||||
import org.alfresco.repo.search.SimpleResultSetMetaData;
|
import org.alfresco.repo.search.SimpleResultSetMetaData;
|
||||||
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
@ -60,6 +61,8 @@ public class LuceneResultSet extends AbstractResultSet
|
|||||||
|
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
|
|
||||||
|
private TenantService tenantService;
|
||||||
|
|
||||||
SearchParameters searchParameters;
|
SearchParameters searchParameters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,12 +71,13 @@ public class LuceneResultSet extends AbstractResultSet
|
|||||||
* @param storeRef
|
* @param storeRef
|
||||||
* @param hits
|
* @param hits
|
||||||
*/
|
*/
|
||||||
public LuceneResultSet(Hits hits, Searcher searcher, NodeService nodeService, Path[]propertyPaths, SearchParameters searchParameters)
|
public LuceneResultSet(Hits hits, Searcher searcher, NodeService nodeService, TenantService tenantService, Path[]propertyPaths, SearchParameters searchParameters)
|
||||||
{
|
{
|
||||||
super(propertyPaths);
|
super(propertyPaths);
|
||||||
this.hits = hits;
|
this.hits = hits;
|
||||||
this.searcher = searcher;
|
this.searcher = searcher;
|
||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
|
this.tenantService = tenantService;
|
||||||
this.searchParameters = searchParameters;
|
this.searchParameters = searchParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +103,7 @@ public class LuceneResultSet extends AbstractResultSet
|
|||||||
// It is possible the store ref is also stored in the index
|
// It is possible the store ref is also stored in the index
|
||||||
Document doc = hits.doc(n);
|
Document doc = hits.doc(n);
|
||||||
String id = doc.get("ID");
|
String id = doc.get("ID");
|
||||||
return new NodeRef(id);
|
return tenantService.getBaseName(new NodeRef(id));
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user