mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -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();
|
||||
}
|
||||
|
||||
}
|
@@ -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 ....
|
||||
}
|
||||
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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
|
||||
}
|
||||
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user