Search in sources :

Example 36 with ResultSet

use of org.alfresco.service.cmr.search.ResultSet in project alfresco-repository by Alfresco.

the class ACLEntryAfterInvocationProvider method decide.

private ResultSet decide(Authentication authentication, Object object, ConfigAttributeDefinition config, PagingLuceneResultSet returnedObject) throws AccessDeniedException {
    ResultSet raw = returnedObject.getWrapped();
    // Check for nested evaluation FilteringResultSet is only wrapped here
    if (raw instanceof FilteringResultSet) {
        return returnedObject;
    }
    ResultSet filteredForPermissions = decide(authentication, object, config, raw);
    PagingLuceneResultSet newPaging = new PagingLuceneResultSet(filteredForPermissions, returnedObject.getResultSetMetaData().getSearchParameters(), nodeService);
    return newPaging;
}
Also used : PagingLuceneResultSet(org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet) ResultSet(org.alfresco.service.cmr.search.ResultSet) CMISResultSet(org.alfresco.opencmis.search.CMISResultSet) SolrJSONResultSet(org.alfresco.repo.search.impl.lucene.SolrJSONResultSet) PagingLuceneResultSet(org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet)

Example 37 with ResultSet

use of org.alfresco.service.cmr.search.ResultSet in project alfresco-repository by Alfresco.

the class ACLEntryAfterInvocationProvider method decide.

private QueryEngineResults decide(Authentication authentication, Object object, ConfigAttributeDefinition config, QueryEngineResults returnedObject) throws AccessDeniedException {
    Map<Set<String>, ResultSet> map = returnedObject.getResults();
    Map<Set<String>, ResultSet> answer = new HashMap<Set<String>, ResultSet>(map.size(), 1.0f);
    for (Set<String> group : map.keySet()) {
        ResultSet raw = map.get(group);
        ResultSet permed;
        if (PagingLuceneResultSet.class.isAssignableFrom(raw.getClass())) {
            permed = decide(authentication, object, config, (PagingLuceneResultSet) raw);
        } else {
            permed = decide(authentication, object, config, raw);
        }
        answer.put(group, permed);
    }
    return new QueryEngineResults(answer);
}
Also used : QueryEngineResults(org.alfresco.repo.search.impl.querymodel.QueryEngineResults) HashSet(java.util.HashSet) PagingLuceneResultSet(org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet) ResultSet(org.alfresco.service.cmr.search.ResultSet) Set(java.util.Set) CMISResultSet(org.alfresco.opencmis.search.CMISResultSet) BitSet(java.util.BitSet) SolrJSONResultSet(org.alfresco.repo.search.impl.lucene.SolrJSONResultSet) HashMap(java.util.HashMap) PagingLuceneResultSet(org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet) ResultSet(org.alfresco.service.cmr.search.ResultSet) CMISResultSet(org.alfresco.opencmis.search.CMISResultSet) SolrJSONResultSet(org.alfresco.repo.search.impl.lucene.SolrJSONResultSet) PagingLuceneResultSet(org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet)

Example 38 with ResultSet

use of org.alfresco.service.cmr.search.ResultSet in project alfresco-repository by Alfresco.

the class AuditMethodInterceptorTest method testAuditSearchServiceSearchParametersQuery.

/**
 * Test for <a href="https://issues.alfresco.com/jira/browse/MNT-16748">MNT-16748</a> <br>
 * Use {@link SearchService#query(SearchParameters)} to perform a query.
 */
public void testAuditSearchServiceSearchParametersQuery() throws Exception {
    // Run as admin
    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
    // Create SearchParameters to be used in query
    SearchParameters sp = new SearchParameters();
    sp.setLanguage(SearchService.LANGUAGE_XPATH);
    sp.setQuery("/app:company_home/app:dictionary");
    sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    // Perform a search
    @SuppressWarnings("unused") ResultSet rs = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<ResultSet>() {

        @Override
        public ResultSet execute() throws Throwable {
            return searchService.query(sp);
        }
    }, true, false);
    // Check the audit entries
    checkAuditEntries(APPLICATION_NAME_MNT_16748, SearchService.LANGUAGE_XPATH, "/app:company_home/app:dictionary", 1);
}
Also used : SearchParameters(org.alfresco.service.cmr.search.SearchParameters) ResultSet(org.alfresco.service.cmr.search.ResultSet)

Example 39 with ResultSet

use of org.alfresco.service.cmr.search.ResultSet in project alfresco-repository by Alfresco.

the class CronScheduledQueryBasedTemplateActionDefinitionTest method checkNodes.

/**
 * Check the nodes to be indexed
 *
 * @param nodes
 * @throws Exception
 */
private void checkNodes(List<FileInfo> nodes) throws Exception {
    SearchService searchService = registry.getSearchService();
    boolean notFound = false;
    for (int i = 1; i <= 40; i++) {
        notFound = false;
        for (FileInfo fileInfo : nodes) {
            ResultSet resultSet = searchService.query(storeRef, SearchService.LANGUAGE_LUCENE, "PATH:\"/app:company_home//cm:" + TEST_FOLDER_NAME + "//cm:" + fileInfo.getName() + "\"");
            if (resultSet.length() == 0) {
                notFound = true;
                break;
            }
        }
        if (notFound) {
            Thread.sleep(500);
        } else {
            break;
        }
    }
    assertFalse("The content was not created or indexed correctly.", notFound);
}
Also used : FileInfo(org.alfresco.service.cmr.model.FileInfo) SearchService(org.alfresco.service.cmr.search.SearchService) ResultSet(org.alfresco.service.cmr.search.ResultSet)

Example 40 with ResultSet

use of org.alfresco.service.cmr.search.ResultSet in project alfresco-repository by Alfresco.

the class CronScheduledQueryBasedTemplateActionDefinition method getNodes.

@Override
public List<NodeRef> getNodes() {
    LinkedList<NodeRef> nodeRefs = new LinkedList<NodeRef>();
    // Build the actual query string
    String queryTemplate = getQueryTemplate();
    // MNT-11598 workaround: de-escape \$\{foo\} or \#\{foo\}
    if (queryTemplate.contains("\\$\\{") || queryTemplate.contains("\\#\\{")) {
        queryTemplate = queryTemplate.replace("\\$\\{", "${");
        queryTemplate = queryTemplate.replace("\\#\\{", "#{");
        if (queryTemplate.contains("\\}")) {
            queryTemplate = queryTemplate.replace("\\}", "}");
        }
    }
    String query = templateService.processTemplateString(getTemplateActionModelFactory().getTemplateEngine(), queryTemplate, getTemplateActionModelFactory().getModel());
    // Execute the query
    SearchParameters sp = new SearchParameters();
    sp.setLanguage(getQueryLanguage());
    sp.setQuery(query);
    for (String storeRef : getStores()) {
        sp.addStore(new StoreRef(storeRef));
    }
    // Transform the reults into a node list
    ResultSet results = null;
    try {
        results = searchService.query(sp);
        for (ResultSetRow row : results) {
            nodeRefs.add(row.getNodeRef());
        }
    } finally {
        if (results != null) {
            results.close();
        }
    }
    return nodeRefs;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) SearchParameters(org.alfresco.service.cmr.search.SearchParameters) StoreRef(org.alfresco.service.cmr.repository.StoreRef) ResultSet(org.alfresco.service.cmr.search.ResultSet) ResultSetRow(org.alfresco.service.cmr.search.ResultSetRow) LinkedList(java.util.LinkedList)

Aggregations

ResultSet (org.alfresco.service.cmr.search.ResultSet)112 NodeRef (org.alfresco.service.cmr.repository.NodeRef)57 SearchParameters (org.alfresco.service.cmr.search.SearchParameters)49 ArrayList (java.util.ArrayList)25 HashMap (java.util.HashMap)22 SolrJSONResultSet (org.alfresco.repo.search.impl.lucene.SolrJSONResultSet)20 Test (org.junit.Test)20 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)17 QName (org.alfresco.service.namespace.QName)16 StoreRef (org.alfresco.service.cmr.repository.StoreRef)14 ResultSetRow (org.alfresco.service.cmr.search.ResultSetRow)14 HashSet (java.util.HashSet)13 EmptyResultSet (org.alfresco.repo.search.EmptyResultSet)13 SearchService (org.alfresco.service.cmr.search.SearchService)13 NodeService (org.alfresco.service.cmr.repository.NodeService)12 IOException (java.io.IOException)11 List (java.util.List)11 SearchRequestContext (org.alfresco.rest.api.search.context.SearchRequestContext)11 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)10 PagingLuceneResultSet (org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet)10