Fix for ALF-10170 Implement "Do Nothing" search subsystem to aid QA testing

- there is now a "noindex" index subsystem
- has debug for all methods - method called and args
- has trace - adds call stack

log4j.logger.org.alfresco.repo.search.impl.noindex.NoIndexIndexer=fatal
log4j.logger.org.alfresco.repo.search.impl.noindex.NoIndexSearchService=fatal

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30403 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind
2011-09-09 20:15:50 +00:00
parent b0d88e65aa
commit 195ea9c810
13 changed files with 1068 additions and 0 deletions

View File

@@ -1070,6 +1070,24 @@
</list> </list>
</property> </property>
</bean> </bean>
<bean id="noindex" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
<property name="autoStart">
<value>false</value>
</property>
<property name="category">
<value>Search</value>
</property>
<property name="typeName">
<value>noindex</value>
</property>
<property name="instancePath">
<list>
<value>managed</value>
<value>noindex</value>
</list>
</property>
</bean>
<bean id="indexerAndSearcherFactory" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory"> <bean id="indexerAndSearcherFactory" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
<property name="sourceApplicationContextFactory"> <property name="sourceApplicationContextFactory">

View File

@@ -0,0 +1,21 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="search.CMISQueryService" class="org.alfresco.repo.search.impl.noindex.NoIndexCMISQueryServiceImpl" >
<property name="cmisDictionaryService">
<ref bean="CMISDictionaryService" />
</property>
<property name="cmisService">
<ref bean="CMISService" />
</property>
<property name="nodeService">
<ref bean="nodeService" />
</property>
<property name="alfrescoDictionaryService">
<ref bean="dictionaryService" />
</property>
</bean>
</beans>

View File

@@ -0,0 +1,2 @@
search.solrTrackingSupport.enabled=true

View File

@@ -0,0 +1,111 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<import resource="../common-search-context.xml" />
<bean id="search.indexerComponent" class="org.alfresco.repo.search.IndexerComponent">
<property name="storeRedirectorProxyFactory">
<ref bean="&amp;search.indexerAndSearcherFactory" />
</property>
</bean>
<bean id="search.searchService" class="org.alfresco.repo.search.SearcherComponent">
<property name="indexerAndSearcherFactory">
<ref bean="search.indexerAndSearcherFactory" />
</property>
</bean>
<bean id="search.admSearchService" class="org.alfresco.repo.search.SearcherComponent">
<property name="indexerAndSearcherFactory">
<ref bean="search.noindexIndexerAndSearcherFactory" />
</property>
</bean>
<bean id="search.versionSearchService" class="org.alfresco.repo.search.SearcherComponent">
<property name="indexerAndSearcherFactory">
<ref bean="search.noindexIndexerAndSearcherFactory" />
</property>
</bean>
<bean id="search.indexerAndSearcherFactory" class="org.alfresco.repo.service.StoreRedirectorProxyFactory">
<property name="proxyInterface">
<value>org.alfresco.repo.search.IndexerAndSearcher</value>
</property>
<property name="defaultBinding">
<ref bean="search.noindexIndexerAndSearcherFactory"></ref>
</property>
</bean>
<bean id="search.noindexIndexerAndSearcherFactory"
class="org.alfresco.repo.search.impl.noindex.NoIndexIndexerAndSearcherFactory">
<property name="nodeService">
<ref bean="mlAwareNodeService" />
</property>
<property name="dictionaryService">
<ref bean="dictionaryService" />
</property>
</bean>
<alias name="search.indexerAndSearcherFactory" alias="search.admLuceneIndexerAndSearcherFactory"/>
<alias name="search.indexerAndSearcherFactory" alias="search.admLuceneUnIndexedIndexerAndSearcherFactory"/>
<alias name="search.indexerAndSearcherFactory" alias="search.avmLuceneIndexerAndSearcherFactory"/>
<bean id="search.categoryService" class="org.alfresco.repo.service.StoreRedirectorProxyFactory">
<property name="proxyInterface">
<value>org.alfresco.service.cmr.search.CategoryService</value>
</property>
<property name="defaultBinding">
<ref bean="search.luceneCategoryService"></ref>
</property>
<property name="redirectedProtocolBindings">
<map>
<entry key="workspace">
<ref bean="search.luceneCategoryService"></ref>
</entry>
<entry key="versionStore">
<ref bean="search.luceneCategoryService"></ref>
</entry>
<entry key="avm">
<ref bean="search.luceneCategoryService"></ref>
</entry>
</map>
</property>
</bean>
<bean id="search.luceneCategoryService" class="org.alfresco.repo.search.impl.noindex.NoIndexCategoryServiceImpl">
<property name="nodeService">
<ref bean="nodeService" />
</property>
<property name="publicNodeService">
<ref bean="NodeService" />
</property>
<property name="tenantService">
<ref bean="tenantService"/>
</property>
<property name="dictionaryService">
<ref bean="dictionaryService" />
</property>
<property name="namespacePrefixResolver">
<ref bean="namespaceService" />
</property>
<property name="indexerAndSearcher">
<ref bean="search.indexerAndSearcherFactory" />
</property>
</bean>
<bean
id="search.indexRecoveryComponent"
class="org.alfresco.repo.search.impl.noindex.NoIndexIndexRecovery" >
</bean>
<alias name="search.indexRecoveryComponent" alias="search.avmIndexRecoveryComponent"/>
<bean id="search.indexConfigurationChecker" class="org.alfresco.repo.admin.DummyIndexConfigurationCheckerImpl">
</bean>
</beans>

View File

@@ -0,0 +1,17 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="search.OpenCMISQueryService" class="org.alfresco.repo.search.impl.noindex.NoIndexOpenCMISQueryServiceImpl" >
<property name="cmisDictionaryService">
<ref bean="OpenCMISDictionaryService" />
</property>
<property name="nodeService">
<ref bean="nodeService" />
</property>
<property name="alfrescoDictionaryService">
<ref bean="dictionaryService" />
</property>
</bean>
</beans>

View File

@@ -0,0 +1,168 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.noindex;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.alfresco.cmis.CMISDictionaryService;
import org.alfresco.cmis.CMISJoinEnum;
import org.alfresco.cmis.CMISQueryEnum;
import org.alfresco.cmis.CMISQueryOptions;
import org.alfresco.cmis.CMISQueryService;
import org.alfresco.cmis.CMISResultSet;
import org.alfresco.cmis.CMISScope;
import org.alfresco.cmis.CMISServices;
import org.alfresco.cmis.CMISQueryOptions.CMISQueryMode;
import org.alfresco.cmis.search.CMISQueryParser;
import org.alfresco.cmis.search.CMISResultSetImpl;
import org.alfresco.cmis.search.CmisFunctionEvaluationContext;
import org.alfresco.repo.search.EmptyResultSet;
import org.alfresco.repo.search.impl.querymodel.Query;
import org.alfresco.repo.search.impl.querymodel.QueryEngineResults;
import org.alfresco.repo.search.impl.querymodel.impl.lucene.LuceneQueryModelFactory;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.LimitBy;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchParameters;
/**
* @author Andy
*
*/
public class NoIndexCMISQueryServiceImpl implements CMISQueryService
{
private CMISServices cmisService;
private CMISDictionaryService cmisDictionaryService;
private NodeService nodeService;
private DictionaryService alfrescoDictionaryService;
public void setCmisService(CMISServices cmisService)
{
this.cmisService = cmisService;
}
public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService)
{
this.cmisDictionaryService = cmisDictionaryService;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setAlfrescoDictionaryService(DictionaryService alfrescoDictionaryService)
{
this.alfrescoDictionaryService = alfrescoDictionaryService;
}
/* (non-Javadoc)
* @see org.alfresco.cmis.CMISQueryService#query(org.alfresco.cmis.CMISQueryOptions)
*/
@Override
public CMISResultSet query(CMISQueryOptions options)
{
ResultSet rs = new EmptyResultSet();
CMISJoinEnum joinSupport = getJoinSupport();
if(options.getQueryMode() == CMISQueryOptions.CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS)
{
joinSupport = CMISJoinEnum.INNER_JOIN_SUPPORT;
}
// TODO: Refactor to avoid duplication of valid scopes here and in CMISQueryParser
CMISScope[] validScopes = (options.getQueryMode() == CMISQueryMode.CMS_STRICT) ? CmisFunctionEvaluationContext.STRICT_SCOPES : CmisFunctionEvaluationContext.ALFRESCO_SCOPES;
CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext();
functionContext.setCmisDictionaryService(cmisDictionaryService);
functionContext.setNodeService(nodeService);
functionContext.setValidScopes(validScopes);
CMISQueryParser parser = new CMISQueryParser(options, cmisDictionaryService, joinSupport);
Query query = parser.parse(new LuceneQueryModelFactory(), functionContext);
Map<String, ResultSet> wrapped = new HashMap<String, ResultSet>();
for (Set<String> group : query.getSource().getSelectorGroups(functionContext))
{
for (String selector : group)
{
wrapped.put(selector, rs);
}
}
LimitBy limitBy = null;
limitBy = rs.getResultSetMetaData().getLimitedBy();
CMISResultSet cmis = new CMISResultSetImpl(wrapped, options, limitBy, nodeService, query, cmisDictionaryService, alfrescoDictionaryService);
return cmis;
}
/* (non-Javadoc)
* @see org.alfresco.cmis.CMISQueryService#query(java.lang.String)
*/
@Override
public CMISResultSet query(String query)
{
CMISQueryOptions options = new CMISQueryOptions(query, cmisService.getDefaultRootStoreRef());
return query(options);
}
/* (non-Javadoc)
* @see org.alfresco.cmis.CMISQueryService#getQuerySupport()
*/
@Override
public CMISQueryEnum getQuerySupport()
{
return CMISQueryEnum.BOTH_COMBINED;
}
/* (non-Javadoc)
* @see org.alfresco.cmis.CMISQueryService#getJoinSupport()
*/
@Override
public CMISJoinEnum getJoinSupport()
{
return CMISJoinEnum.NO_JOIN_SUPPORT;
}
/* (non-Javadoc)
* @see org.alfresco.cmis.CMISQueryService#getPwcSearchable()
*/
@Override
public boolean getPwcSearchable()
{
return true;
}
/* (non-Javadoc)
* @see org.alfresco.cmis.CMISQueryService#getAllVersionsSearchable()
*/
@Override
public boolean getAllVersionsSearchable()
{
return false;
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.noindex;
import java.util.Collections;
import java.util.List;
import org.alfresco.repo.search.impl.lucene.LuceneCategoryServiceImpl;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
/**
* @author Andy
*
*/
public class NoIndexCategoryServiceImpl extends LuceneCategoryServiceImpl
{
@Override
public List<Pair<NodeRef, Integer>> getTopCategories(StoreRef storeRef, QName aspectName, int count)
{
return Collections.<Pair<NodeRef, Integer>>emptyList();
}
}

View File

@@ -0,0 +1,40 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.noindex;
import org.alfresco.repo.node.index.IndexRecovery;
/**
* @author Andy
*
*/
public class NoIndexIndexRecovery implements IndexRecovery
{
/* (non-Javadoc)
* @see org.alfresco.repo.node.index.IndexRecovery#reindex()
*/
@Override
public void reindex()
{
// Nothing to do at the moment
// Should send check and recovery commands etc when we support them ....
}
}

View File

@@ -0,0 +1,153 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.noindex;
import org.alfresco.error.StackTraceUtil;
import org.alfresco.repo.search.Indexer;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* A no action indexer - the indexing is done automatically along with
* persistence
*
* TODO: Rename to Adaptor?
*
* @author andyh
*
*/
public class NoIndexIndexer implements Indexer
{
private static Log s_logger = LogFactory.getLog(NoIndexIndexer.class);
public void setReadThrough(boolean isReadThrough)
{
if(s_logger.isDebugEnabled())
{
s_logger.debug("setReadThrough = "+isReadThrough);
}
trace();
return;
}
private void trace()
{
if(s_logger.isTraceEnabled())
{
Exception e = new Exception();
e.fillInStackTrace();
StringBuilder sb = new StringBuilder(1024);
StackTraceUtil.buildStackTrace(
"Index trace ...",
e.getStackTrace(),
sb,
-1);
s_logger.trace(sb);
}
}
public void createNode(ChildAssociationRef relationshipRef)
{
if(s_logger.isDebugEnabled())
{
s_logger.debug("createNode = "+relationshipRef);
}
trace();
return;
}
public void updateNode(NodeRef nodeRef)
{
if(s_logger.isDebugEnabled())
{
s_logger.debug("updateNode = "+nodeRef);
}
trace();
return;
}
public void deleteNode(ChildAssociationRef relationshipRef)
{
if(s_logger.isDebugEnabled())
{
s_logger.debug("deleteNode = "+relationshipRef);
}
trace();
return;
}
public void createChildRelationship(ChildAssociationRef relationshipRef)
{
if(s_logger.isDebugEnabled())
{
s_logger.debug("createChildRelationship = "+relationshipRef);
}
trace();
return;
}
public void updateChildRelationship(ChildAssociationRef relationshipBeforeRef, ChildAssociationRef relationshipAfterRef)
{
if(s_logger.isDebugEnabled())
{
s_logger.debug("updateChildRelationship = "+relationshipBeforeRef+ " -> "+relationshipAfterRef);
}
trace();
return;
}
public void deleteChildRelationship(ChildAssociationRef relationshipRef)
{
if(s_logger.isDebugEnabled())
{
s_logger.debug("deleteChildRelationship = "+relationshipRef);
}
trace();
return;
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.Indexer#deleteIndex(org.alfresco.service.cmr.repository.StoreRef)
*/
public void deleteIndex(StoreRef storeRef)
{
if(s_logger.isDebugEnabled())
{
s_logger.debug("deleteIndex = "+storeRef);
}
trace();
return;
}
public void flushPending()
{
if(s_logger.isDebugEnabled())
{
s_logger.debug("flushPending");
}
trace();
return;
}
}

View File

@@ -0,0 +1,94 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.noindex;
import org.alfresco.repo.search.Indexer;
import org.alfresco.repo.search.IndexerException;
import org.alfresco.repo.search.SearcherException;
import org.alfresco.repo.search.impl.lucene.AbstractIndexerAndSearcher;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService;
/**
* @author Andy
*
*/
public class NoIndexIndexerAndSearcherFactory extends AbstractIndexerAndSearcher
{
private DictionaryService dictionaryService;
private NodeService nodeService;
public DictionaryService getDictionaryService()
{
return dictionaryService;
}
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
public NodeService getNodeService()
{
return nodeService;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.IndexerAndSearcher#getIndexer(org.alfresco.service.cmr.repository.StoreRef)
*/
@Override
public Indexer getIndexer(StoreRef storeRef) throws IndexerException
{
NoIndexIndexer indexer = new NoIndexIndexer();
return indexer;
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.IndexerAndSearcher#getSearcher(org.alfresco.service.cmr.repository.StoreRef, boolean)
*/
@Override
public SearchService getSearcher(StoreRef storeRef, boolean searchDelta) throws SearcherException
{
//storeRef = tenantService.getName(storeRef);
NoIndexSearchService searchService = new NoIndexSearchService();
searchService.setDictionaryService(dictionaryService);
searchService.setNodeService(nodeService);
return searchService;
}
/* (non-Javadoc)
* @see org.alfresco.repo.search.IndexerAndSearcher#flush()
*/
@Override
public void flush()
{
// Nothing to do
}
}

View File

@@ -0,0 +1,141 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.noindex;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import org.alfresco.opencmis.dictionary.CMISDictionaryService;
import org.alfresco.opencmis.search.CMISQueryOptions;
import org.alfresco.opencmis.search.CMISQueryOptions.CMISQueryMode;
import org.alfresco.opencmis.search.CMISQueryParser;
import org.alfresco.opencmis.search.CMISQueryService;
import org.alfresco.opencmis.search.CMISResultSet;
import org.alfresco.opencmis.search.CmisFunctionEvaluationContext;
import org.alfresco.repo.search.EmptyResultSet;
import org.alfresco.repo.search.impl.querymodel.Query;
import org.alfresco.repo.search.impl.querymodel.impl.lucene.LuceneQueryModelFactory;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.LimitBy;
import org.alfresco.service.cmr.search.ResultSet;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.chemistry.opencmis.commons.enums.CapabilityJoin;
import org.apache.chemistry.opencmis.commons.enums.CapabilityQuery;
/**
* @author Andy
*
*/
public class NoIndexOpenCMISQueryServiceImpl implements CMISQueryService
{
private NodeService nodeService;
private DictionaryService alfrescoDictionaryService;
private CMISDictionaryService cmisDictionaryService;
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setAlfrescoDictionaryService(DictionaryService alfrescoDictionaryService)
{
this.alfrescoDictionaryService = alfrescoDictionaryService;
}
public void setCmisDictionaryService(CMISDictionaryService cmisDictionaryService)
{
this.cmisDictionaryService = cmisDictionaryService;
}
/* (non-Javadoc)
* @see org.alfresco.opencmis.search.CMISQueryService#query(org.alfresco.opencmis.search.CMISQueryOptions)
*/
@Override
public CMISResultSet query(CMISQueryOptions options)
{
ResultSet rs = new EmptyResultSet();
CapabilityJoin joinSupport = getJoinSupport();
if(options.getQueryMode() == CMISQueryOptions.CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS)
{
joinSupport = CapabilityJoin.INNERONLY;
}
// TODO: Refactor to avoid duplication of valid scopes here and in CMISQueryParser
BaseTypeId[] validScopes = (options.getQueryMode() == CMISQueryMode.CMS_STRICT) ? CmisFunctionEvaluationContext.STRICT_SCOPES : CmisFunctionEvaluationContext.ALFRESCO_SCOPES;
CmisFunctionEvaluationContext functionContext = new CmisFunctionEvaluationContext();
functionContext.setCmisDictionaryService(cmisDictionaryService);
functionContext.setNodeService(nodeService);
functionContext.setValidScopes(validScopes);
CMISQueryParser parser = new CMISQueryParser(options, cmisDictionaryService, joinSupport);
Query query = parser.parse(new LuceneQueryModelFactory(), functionContext);
Map<String, ResultSet> wrapped = new HashMap<String, ResultSet>();
for (Set<String> group : query.getSource().getSelectorGroups(functionContext))
{
for (String selector : group)
{
wrapped.put(selector, rs);
}
}
LimitBy limitBy = null;
limitBy = rs.getResultSetMetaData().getLimitedBy();
CMISResultSet cmis = new CMISResultSet(wrapped, options, limitBy, nodeService, query, cmisDictionaryService, alfrescoDictionaryService);
return cmis;
}
/* (non-Javadoc)
* @see org.alfresco.opencmis.search.CMISQueryService#query(java.lang.String, org.alfresco.service.cmr.repository.StoreRef)
*/
@Override
public CMISResultSet query(String query, StoreRef storeRef)
{
CMISQueryOptions options = new CMISQueryOptions(query, storeRef);
return query(options);
}
public boolean getPwcSearchable()
{
return true;
}
public boolean getAllVersionsSearchable()
{
return false;
}
public CapabilityQuery getQuerySupport()
{
return CapabilityQuery.BOTHCOMBINED;
}
public CapabilityJoin getJoinSupport()
{
return CapabilityJoin.NONE;
}
}

View File

@@ -0,0 +1,260 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.search.impl.noindex;
import java.io.Serializable;
import java.util.List;
import org.alfresco.error.StackTraceUtil;
import org.alfresco.repo.search.EmptyResultSet;
import org.alfresco.repo.search.impl.NodeSearcher;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.XPathException;
import org.alfresco.service.cmr.search.QueryParameter;
import org.alfresco.service.cmr.search.QueryParameterDefinition;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchParameters.Operator;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespacePrefixResolver;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* @author Andy
* log4j:logger=org.alfresco.repo.search.impl.noindex.NoIndexSearchService
*/
public class NoIndexSearchService implements SearchService
{
private static Log s_logger = LogFactory.getLog(NoIndexSearchService.class);
private NodeService nodeService;
private DictionaryService dictionaryService;
public NodeService getNodeService()
{
return nodeService;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public DictionaryService getDictionaryService()
{
return dictionaryService;
}
public void setDictionaryService(DictionaryService dictionaryService)
{
this.dictionaryService = dictionaryService;
}
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.search.SearchService#query(org.alfresco.service.cmr.repository.StoreRef,
* java.lang.String, java.lang.String)
*/
@Override
public ResultSet query(StoreRef store, String language, String query)
{
if (s_logger.isDebugEnabled())
{
s_logger.debug("query store = " + store + " language = " + language + " query = " + query);
}
trace();
return new EmptyResultSet();
}
private void trace()
{
if (s_logger.isTraceEnabled())
{
Exception e = new Exception();
e.fillInStackTrace();
StringBuilder sb = new StringBuilder(1024);
StackTraceUtil.buildStackTrace("Search trace ...", e.getStackTrace(), sb, -1);
s_logger.trace(sb);
}
}
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.search.SearchService#query(org.alfresco.service.cmr.repository.StoreRef,
* java.lang.String, java.lang.String, org.alfresco.service.cmr.search.QueryParameterDefinition[])
*/
@Override
public ResultSet query(StoreRef store, String language, String query, QueryParameterDefinition[] queryParameterDefinitions)
{
if (s_logger.isDebugEnabled())
{
s_logger.debug("query store = " + store + " language = " + language + " query = " + query + " queryParameterDefinitions = " + queryParameterDefinitions);
}
trace();
return new EmptyResultSet();
}
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.search.SearchService#query(org.alfresco.service.cmr.repository.StoreRef,
* org.alfresco.service.namespace.QName, org.alfresco.service.cmr.search.QueryParameter[])
*/
@Override
public ResultSet query(StoreRef store, QName queryId, QueryParameter[] queryParameters)
{
if (s_logger.isDebugEnabled())
{
s_logger.debug("query store = " + store + " queryId = " + queryId + " queryParameters = " + queryParameters);
}
trace();
return new EmptyResultSet();
}
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.search.SearchService#query(org.alfresco.service.cmr.search.SearchParameters)
*/
@Override
public ResultSet query(SearchParameters searchParameters)
{
if (s_logger.isDebugEnabled())
{
s_logger.debug("query searchParameters = " + searchParameters);
}
trace();
return new EmptyResultSet();
}
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.search.SearchService#selectNodes(org.alfresco.service.cmr.repository.NodeRef,
* java.lang.String, org.alfresco.service.cmr.search.QueryParameterDefinition[],
* org.alfresco.service.namespace.NamespacePrefixResolver, boolean)
*/
@Override
public List<NodeRef> selectNodes(NodeRef contextNodeRef, String xpath, QueryParameterDefinition[] parameters, NamespacePrefixResolver namespacePrefixResolver,
boolean followAllParentLinks) throws InvalidNodeRefException, XPathException
{
return selectNodes(contextNodeRef, xpath, parameters, namespacePrefixResolver, followAllParentLinks, SearchService.LANGUAGE_XPATH);
}
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.search.SearchService#selectNodes(org.alfresco.service.cmr.repository.NodeRef,
* java.lang.String, org.alfresco.service.cmr.search.QueryParameterDefinition[],
* org.alfresco.service.namespace.NamespacePrefixResolver, boolean, java.lang.String)
*/
@Override
public List<NodeRef> selectNodes(NodeRef contextNodeRef, String xpath, QueryParameterDefinition[] parameters, NamespacePrefixResolver namespacePrefixResolver,
boolean followAllParentLinks, String language) throws InvalidNodeRefException, XPathException
{
NodeSearcher nodeSearcher = new NodeSearcher(nodeService, dictionaryService, this);
return nodeSearcher.selectNodes(contextNodeRef, xpath, parameters, namespacePrefixResolver, followAllParentLinks, language);
}
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.search.SearchService#selectProperties(org.alfresco.service.cmr.repository.NodeRef,
* java.lang.String, org.alfresco.service.cmr.search.QueryParameterDefinition[],
* org.alfresco.service.namespace.NamespacePrefixResolver, boolean)
*/
@Override
public List<Serializable> selectProperties(NodeRef contextNodeRef, String xpath, QueryParameterDefinition[] parameters, NamespacePrefixResolver namespacePrefixResolver,
boolean followAllParentLinks) throws InvalidNodeRefException, XPathException
{
return selectProperties(contextNodeRef, xpath, parameters, namespacePrefixResolver, followAllParentLinks, SearchService.LANGUAGE_XPATH);
}
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.search.SearchService#selectProperties(org.alfresco.service.cmr.repository.NodeRef,
* java.lang.String, org.alfresco.service.cmr.search.QueryParameterDefinition[],
* org.alfresco.service.namespace.NamespacePrefixResolver, boolean, java.lang.String)
*/
@Override
public List<Serializable> selectProperties(NodeRef contextNodeRef, String xpath, QueryParameterDefinition[] parameters, NamespacePrefixResolver namespacePrefixResolver,
boolean followAllParentLinks, String language) throws InvalidNodeRefException, XPathException
{
NodeSearcher nodeSearcher = new NodeSearcher(nodeService, dictionaryService, this);
return nodeSearcher.selectProperties(contextNodeRef, xpath, parameters, namespacePrefixResolver, followAllParentLinks, language);
}
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.search.SearchService#contains(org.alfresco.service.cmr.repository.NodeRef,
* org.alfresco.service.namespace.QName, java.lang.String)
*/
@Override
public boolean contains(NodeRef nodeRef, QName propertyQName, String googleLikePattern) throws InvalidNodeRefException
{
return contains(nodeRef, propertyQName, googleLikePattern, SearchParameters.Operator.OR);
}
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.search.SearchService#contains(org.alfresco.service.cmr.repository.NodeRef,
* org.alfresco.service.namespace.QName, java.lang.String,
* org.alfresco.service.cmr.search.SearchParameters.Operator)
*/
@Override
public boolean contains(NodeRef nodeRef, QName propertyQName, String googleLikePattern, Operator defaultOperator) throws InvalidNodeRefException
{
if (s_logger.isDebugEnabled())
{
s_logger.debug("contains nodeRef = "
+ nodeRef + " propertyQName = " + propertyQName + " googleLikePattern = " + googleLikePattern + " defaultOperator = " + defaultOperator);
}
trace();
return false;
}
/*
* (non-Javadoc)
* @see org.alfresco.service.cmr.search.SearchService#like(org.alfresco.service.cmr.repository.NodeRef,
* org.alfresco.service.namespace.QName, java.lang.String, boolean)
*/
@Override
public boolean like(NodeRef nodeRef, QName propertyQName, String sqlLikePattern, boolean includeFTS) throws InvalidNodeRefException
{
// only inlcude FTS depends on the index ...
if (includeFTS)
{
if (s_logger.isDebugEnabled())
{
s_logger.debug("contains nodeRef = "
+ nodeRef + " propertyQName = " + propertyQName + " sqlLikePattern = " + sqlLikePattern + " includeFTS = " + includeFTS);
}
trace();
}
return false;
}
}