当前位置: 首页>>代码示例>>Java>>正文


Java ResultSet.close方法代码示例

本文整理汇总了Java中org.alfresco.service.cmr.search.ResultSet.close方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.close方法的具体用法?Java ResultSet.close怎么用?Java ResultSet.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.service.cmr.search.ResultSet的用法示例。


在下文中一共展示了ResultSet.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findTaggedNodes

import org.alfresco.service.cmr.search.ResultSet; //导入方法依赖的package包/类
/**
 * @see org.alfresco.service.cmr.tagging.TaggingService#findTaggedNodes(StoreRef, java.lang.String)
 */
public List<NodeRef> findTaggedNodes(StoreRef storeRef, String tag)
{
    // Lower the case of the tag
    tag = tag.toLowerCase();
    ResultSet resultSet= null;
    
    try
    {
        // Do the search for nodes
        resultSet = this.searchService.query(
            storeRef, 
            SearchService.LANGUAGE_LUCENE, 
            "+PATH:\"/cm:taggable/cm:" + ISO9075.encode(tag) + "/member\"");
        List<NodeRef> nodeRefs = resultSet.getNodeRefs();
        return nodeRefs;
    }
    finally
    {
        if(resultSet != null) {resultSet.close();}
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:TaggingServiceImpl.java

示例2: queryWithCount

import org.alfresco.service.cmr.search.ResultSet; //导入方法依赖的package包/类
public void queryWithCount(String ql, String query, int count, QName property, Boolean ascending)
{
    SearchParameters sp = new SearchParameters();
    sp.setLanguage(ql);
    sp.setQueryConsistency(QueryConsistency.TRANSACTIONAL);
    sp.setQuery(query);
    sp.addStore(rootNodeRef.getStoreRef());
    ResultSet results = serviceRegistry.getSearchService().query(sp);
    HashSet<NodeRef> found = new HashSet<NodeRef>();
    Comparable last = null;
    for(ResultSetRow row :results)
    {
        assertFalse(found.contains( row.getNodeRef()));
        found.add(row.getNodeRef());
        if(property != null)
        {
            Comparable current = (Comparable)nodeService.getProperty(row.getNodeRef(), property);
            if(last != null)
            {
                if((ascending == null) || (ascending))
                {
                    assert(last.compareTo(current) >= 0);
                }
                else
                {
                    assert(last.compareTo(current) <= 0);
                }
                        
            }
            last = current;
        }
    }
    assertEquals(count, results.length());
    results.getResultSetMetaData();
    results.close();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:37,代码来源:DBQueryTest.java

示例3: getNodeFromPathName

import org.alfresco.service.cmr.search.ResultSet; //导入方法依赖的package包/类
public NodeRef getNodeFromPathName(String pathName) {
	StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
	ResultSet rs = searchService.query(storeRef, SearchService.LANGUAGE_XPATH, String.format("/app:%s", pathName));

	NodeRef sourceNameNodeRef = null;
	try {
		if (rs.length() == 0) {
			throw new AlfrescoRuntimeException(String.format("Didn't find %s", pathName));
		}
		sourceNameNodeRef = rs.getNodeRef(0);
	} finally {
		rs.close();
	}
	return sourceNameNodeRef;
}
 
开发者ID:Vitezslav-Sliz,项目名称:tieto-alfresco-repository_monitor,代码行数:16,代码来源:NodesHierarchyJobImpl.java

示例4: testConcurrent

import org.alfresco.service.cmr.search.ResultSet; //导入方法依赖的package包/类
public void testConcurrent() throws Exception
{
    int count = 10;
    int repeats = 10;

    SearchService searcher = (SearchService) ctx.getBean(ServiceRegistry.SEARCH_SERVICE.getLocalName());

    Map<QName, ChildAssociationRef> assocRefs = commitNodeGraph();
    Thread runner = null;

    for (int i = 0; i < count; i++)
    {
        runner = new Nester("Concurrent-" + i, runner, repeats, searcher);
    }
    if (runner != null)
    {
        runner.start();

        try
        {
            runner.join();
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }
    }

    assertEquals(2, searcher.selectNodes(rootNodeRef, "/*", null,
            getNamespacePrefixReolsver(""), false).size());
    ResultSet results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*\"");
    // n6 has root aspect - there are three things at the root level in the
    // index
    assertEquals(3, results.length());
    results.close();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:37,代码来源:ConcurrentNodeServiceSearchTest.java

示例5: isTxnIdPresentInIndex

import org.alfresco.service.cmr.search.ResultSet; //导入方法依赖的package包/类
/**
 * @return                  Returns true if the given transaction is present in the index
 */
private boolean isTxnIdPresentInIndex(StoreRef storeRef, Transaction txn)
{
    long txnId = txn.getId();
    String changeTxnId = txn.getChangeTxnId();
    // do the most update check, which is most common
    ResultSet results = null;
    try
    {
        SearchParameters sp = new SearchParameters();
        sp.addStore(storeRef);
        // search for it in the index, sorting with youngest first, fetching only 1
        sp.setLanguage(SearchService.LANGUAGE_LUCENE);
        sp.setQuery("TX:" + SearchLanguageConversion.escapeLuceneQuery(changeTxnId));
        sp.setLimit(1);
        
        results = searcher.query(sp);
        
        if (results.length() > 0)
        {
            if (logger.isTraceEnabled())
            {
                logger.trace("Index has results for txn " + txnId + " for store " + storeRef);
            }
            return true;        // there were updates/creates and results for the txn were found
        }
        else
        {
            if (logger.isTraceEnabled())
            {
                logger.trace("Transaction " + txnId + " not in index for store " + storeRef + ".  Possibly out of date.");
            }
            return false;
        }
    }
    finally
    {
        if (results != null) { results.close(); }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:43,代码来源:AbstractReindexComponent.java

示例6: getUsername

import org.alfresco.service.cmr.search.ResultSet; //导入方法依赖的package包/类
/**
 * Authenticate in Alfresco repository by sender's e-mail address.
 * 
 * @param from Sender's email address
 * @return User name or null if the user does not exist.
 * @throws EmailMessageException Exception will be thrown if authentication is failed.
 */
private String getUsername(String from)
{
    String userName = null;
    
    if(from == null || from.length()==0)
    {
        return null;
    }
    
    if(logger.isDebugEnabled())
    {
        logger.debug("getUsername from: " + from);
    }
    
    
    StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
    String query = "TYPE:cm\\:person AND [email protected]\\:email:\"" + from + "\"";

    ResultSet resultSet = searchService.query(storeRef, SearchService.LANGUAGE_FTS_ALFRESCO, query);
    try
    {
        if (resultSet == null || resultSet.length() == 0)
        {
            return null;
        }
        if (resultSet.length() > 1)
        {
            if(logger.isWarnEnabled())
            {
                logger.warn("found more as one result for email '" + from + "'. The first will be used");
            }
        }
        NodeRef userNode = resultSet.getNodeRef(0);
        if (nodeService.exists(userNode))
        {
            userName = DefaultTypeConverter.INSTANCE.convert(
                    String.class,
                    nodeService.getProperty(userNode, ContentModel.PROP_USERNAME));

            if(logger.isDebugEnabled())
            {
                logger.debug("found username: " + userName);
            }
        }
        else
        {
            // The Lucene index returned a dead result
            throw new EmailMessageException(ERR_UNKNOWN_SOURCE_ADDRESS, from);
        }
    }
    finally
    {
        if(resultSet != null)
        {
            resultSet.close();
        }
    }

    return userName;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:68,代码来源:EmailServiceImpl.java

示例7: findSites

import org.alfresco.service.cmr.search.ResultSet; //导入方法依赖的package包/类
@Override
public List<SiteInfo> findSites(String filter, String sitePresetFilter, int size)
{
    List<SiteInfo> result;
    
    NodeRef siteRoot = getSiteRoot();
    if (siteRoot == null)
    {
        result = Collections.emptyList();
    }
    else
    {
        // get the sites that match the specified names
        StringBuilder query = new StringBuilder(128);
        query.append("+PARENT:\"").append(siteRoot.toString()).append('"');

        final boolean filterIsPresent = filter != null && filter.length() > 0;
        // The filter string is only used in the Lucene query if it restricts results.
        // A search for name/title/description = "*" does not need to be put into the Lucene query.
        // This allows users to search for "*" in the site-finder.
        final boolean filterIsPresentAndNecessary = filterIsPresent && !filter.equals("*");
        final boolean sitePresetFilterIsPresent = sitePresetFilter != null && sitePresetFilter.length() > 0;
        
        if (filterIsPresentAndNecessary || sitePresetFilterIsPresent)
        {
            query.append(" +(");
            if (filterIsPresentAndNecessary)
            {
                String escNameFilter = SearchLanguageConversion.escapeLuceneQuery(filter.replace('"', ' '));
                
                query.append(" @cm\\:name:\"*" + escNameFilter + "*\"")
                     .append(" @cm\\:title:\"" + escNameFilter + "\"")
                     .append(" @cm\\:description:\"" + escNameFilter + "\"");
            }
            if (sitePresetFilterIsPresent)
            {
                String escPresetFilter = SearchLanguageConversion.escapeLuceneQuery(sitePresetFilter.replace('"', ' '));
                query.append(" @st\\:sitePreset:\"" + escPresetFilter + "\"");
            }
            
            query.append(")");
        }
        
        SearchParameters sp = new SearchParameters();
        sp.addStore(siteRoot.getStoreRef());
        sp.setLanguage(SearchService.LANGUAGE_LUCENE);
        sp.setQuery(query.toString());
        if (size > 0)
        {
            sp.setLimit(size);
            sp.setLimitBy(LimitBy.FINAL_SIZE);
        }
        ResultSet results = this.searchService.query(sp);
        try
        {
            result = new ArrayList<SiteInfo>(results.length());
            for (NodeRef site : results.getNodeRefs())
            {
                // Ignore any node type that is not a "site"
                QName siteClassName = this.nodeService.getType(site);
                if (this.dictionaryService.isSubClass(siteClassName, SiteModel.TYPE_SITE))
                {
                    result.add(createSiteInfo(site));
                }
            }
        }
        finally
        {
            results.close();
        }
    }
    
    return result;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:75,代码来源:SiteServiceImpl.java

示例8: contains

import org.alfresco.service.cmr.search.ResultSet; //导入方法依赖的package包/类
/**
 * @return Returns true if the pattern is present, otherwise false.
 */
public boolean contains(NodeRef nodeRef, QName propertyQName, String googleLikePattern, SearchParameters.Operator defaultOperator)
{
    ResultSet resultSet = null;
    try
    {
        // build Lucene search string specific to the node
        StringBuilder sb = new StringBuilder();
        sb.append("+ID:\"").append(nodeRef.toString()).append("\" +(TEXT:(").append(googleLikePattern.toLowerCase()).append(") ");
        if (propertyQName != null)
        {
            sb.append(" OR @").append(SearchLanguageConversion.escapeLuceneQuery(QName.createQName(propertyQName.getNamespaceURI(), ISO9075.encode(propertyQName.getLocalName())).toString()));
            sb.append(":(").append(googleLikePattern.toLowerCase()).append(")");
        }
        else
        {
            for (QName key : nodeService.getProperties(nodeRef).keySet())
            {
                sb.append(" OR @").append(SearchLanguageConversion.escapeLuceneQuery(QName.createQName(key.getNamespaceURI(), ISO9075.encode(key.getLocalName())).toString()));
                sb.append(":(").append(googleLikePattern.toLowerCase()).append(")");
            }
        }
        sb.append(")");

        SearchParameters sp = new SearchParameters();
        sp.setLanguage(SearchService.LANGUAGE_LUCENE);
        sp.setQuery(sb.toString());
        sp.setDefaultOperator(defaultOperator);
        sp.addStore(nodeRef.getStoreRef());

        resultSet = this.query(sp);
        boolean answer = resultSet.length() > 0;
        return answer;
    }
    finally
    {
        if (resultSet != null)
        {
            resultSet.close();
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:45,代码来源:ADMLuceneSearcherImpl.java

示例9: find

import org.alfresco.service.cmr.search.ResultSet; //导入方法依赖的package包/类
public CollectionWithPagingInfo<T> find(Parameters parameters,
    String termName, int minTermLength, String queryTemplateName,
    Sort sort, Map<String, QName> sortParamsToQNames, SortColumn... defaultSort)
{
    SearchParameters sp = new SearchParameters();
    sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
    sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    sp.setDefaultFieldName(queryTemplateName);
    
    String term = getTerm(parameters, termName, minTermLength);

    StringBuilder query = new StringBuilder();
    buildQuery(query, term, sp, queryTemplateName);
    sp.setQuery(query.toString());

    Paging paging = parameters.getPaging();
    PagingRequest pagingRequest = Util.getPagingRequest(paging);
    
    List<SortColumn> defaultSortCols = (defaultSort != null ? Arrays.asList(defaultSort) : Collections.emptyList());
    if (sort == IN_QUERY_SORT)
    {
        addSortOrder(parameters, sortParamsToQNames, defaultSortCols, sp);

        sp.setSkipCount(pagingRequest.getSkipCount());
        sp.setMaxItems(pagingRequest.getMaxItems());
    }
    
    ResultSet queryResults = null;
    List<T> collection = null;
    try
    {
        queryResults = searchService.query(sp);
        
        List<NodeRef> nodeRefs = queryResults.getNodeRefs();
        
        if (sort == POST_QUERY_SORT)
        {
            nodeRefs = postQuerySort(parameters, sortParamsToQNames, defaultSortCols, nodeRefs);
        }
        
        collection = newList(nodeRefs.size());
        List<String> includeParam = parameters.getInclude();

        for (NodeRef nodeRef : nodeRefs)
        {
            T t = convert(nodeRef, includeParam);
            collection.add(t);
        }

        if (sort == POST_QUERY_SORT)
        {
            return listPage(collection, paging);
        }
        else
        {
            return CollectionWithPagingInfo.asPaged(paging, collection, queryResults.hasMore(), new Long(queryResults.getNumberFound()).intValue());
        }
    }
    finally
    {
        if (queryResults != null)
        {
            queryResults.close();
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:67,代码来源:QueriesImpl.java

示例10: detectNodeChanges

import org.alfresco.service.cmr.search.ResultSet; //导入方法依赖的package包/类
public void detectNodeChanges(NodeRef nodeRef, SearchService searcher,
        Collection<ChildAssociationRef> addedParents, Collection<ChildAssociationRef> deletedParents,
        Collection<ChildAssociationRef> createdNodes, Collection<NodeRef> updatedNodes) throws LuceneIndexException
{
    boolean nodeExisted = false;
    boolean relationshipsChanged = false;
    
    ResultSet results = null;
    SearchParameters sp = new SearchParameters();
    sp.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp.addStore(nodeRef.getStoreRef());
    try
    {
        sp.setQuery("ID:" + SearchLanguageConversion.escapeLuceneQuery(nodeRef.toString()));
        results = searcher.query(sp);
        for (ResultSetRow row : results)
        {
            nodeExisted = true;
            Document document = ((LuceneResultSetRow) row).getDocument();
            Field qname = document.getField("QNAME");
            if (qname == null)
            {
                continue;
            }
            Collection<Pair<ChildAssociationRef, QName>> allParents = getAllParents(nodeRef, nodeService.getProperties(nodeRef));
            Set<ChildAssociationRef> dbParents = new HashSet<ChildAssociationRef>(allParents.size() * 2);
            for (Pair<ChildAssociationRef, QName> pair : allParents)
            {
                ChildAssociationRef qNameRef = tenantService.getName(pair.getFirst());
                if ((qNameRef != null) && (qNameRef.getParentRef() != null) && (qNameRef.getQName() != null))
                {
                    dbParents.add(new ChildAssociationRef(ContentModel.ASSOC_CHILDREN, qNameRef.getParentRef(), qNameRef.getQName(), qNameRef.getChildRef()));
                }
            }
                           
            Field[] parents = document.getFields("PARENT");
            String[] qnames = qname.stringValue().split(";/");
            Set<ChildAssociationRef> addedParentsSet = new HashSet<ChildAssociationRef>(dbParents);
            for (int i=0; i<Math.min(parents.length, qnames.length); i++)
            {
                QName parentQname = QName.createQName(qnames[i]);
                parentQname = QName.createQName(parentQname.getNamespaceURI(), ISO9075.decode(parentQname.getLocalName()));
                NodeRef parentRef = new NodeRef(parents[i].stringValue());
                ChildAssociationRef indexedParent = new ChildAssociationRef(ContentModel.ASSOC_CHILDREN, parentRef, parentQname, nodeRef);
                if (!addedParentsSet.remove(indexedParent))
                {
                    deletedParents.add(indexedParent);                        
                    relationshipsChanged = true;
                }
            }
            if (addedParents.addAll(addedParentsSet))
            {
                relationshipsChanged = true;
            }

            break;
        }

        if (!nodeExisted)
        {
            createdNodes.add(nodeService.getPrimaryParent(nodeRef));
        }
        else if (!relationshipsChanged)
        {
            updatedNodes.add(nodeRef);
        }
    }
    finally
    {
        if (results != null) { results.close(); }
    }
    
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:74,代码来源:ADMLuceneIndexerImpl.java

示例11: getTopCategories

import org.alfresco.service.cmr.search.ResultSet; //导入方法依赖的package包/类
@Override
public List<Pair<NodeRef, Integer>> getTopCategories(StoreRef storeRef, QName aspectName, int count)
{
    AspectDefinition definition = dictionaryService.getAspect(aspectName);
    if(definition == null)
    {
        throw new IllegalStateException("Unknown aspect");
    }
    QName catProperty = null;
    Map<QName, PropertyDefinition> properties = definition.getProperties();
    for(QName pName : properties.keySet())
    {
        if(pName.getNamespaceURI().equals(aspectName.getNamespaceURI()))
        {
            if(pName.getLocalName().equalsIgnoreCase(aspectName.getLocalName()))
            {
                PropertyDefinition def = properties.get(pName);
                if(def.getDataType().getName().equals(DataTypeDefinition.CATEGORY))
                {
                    catProperty = pName;
                }
            }
        }
    }
    if(catProperty == null)
    {
        throw new IllegalStateException("Aspect does not have category property mirroring the aspect name");
    }
    
    String field = "@" + catProperty;
    
    SearchParameters sp = new SearchParameters();
    sp.setLanguage(SearchService.LANGUAGE_SOLR_FTS_ALFRESCO);
    sp.addStore(storeRef);
    sp.setQuery(catProperty+":*");
    FieldFacet ff = new FieldFacet(field);
    ff.setLimitOrNull(count);
    sp.addFieldFacet(ff);
    
    ResultSet resultSet = null;
    try
    {
        resultSet = indexerAndSearcher.getSearcher(storeRef, false).query(sp);
        List<Pair<String, Integer>> facetCounts = resultSet.getFieldFacet(field);
        List<Pair<NodeRef, Integer>> answer = new LinkedList<Pair<NodeRef, Integer>>();
        for (Pair<String, Integer> term : facetCounts)
        {
            Pair<NodeRef, Integer> toAdd;
            NodeRef nodeRef = new NodeRef(term.getFirst());
            if (nodeService.exists(nodeRef))
            {
                toAdd = new Pair<NodeRef, Integer>(nodeRef, term.getSecond());
            }
            else
            {
                toAdd = new Pair<NodeRef, Integer>(null, term.getSecond());
            }
            answer.add(toAdd);
        }
        return answer;
    }
    finally
    {
        if (resultSet != null)
        {
            resultSet.close();
        }
    }
    
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:71,代码来源:SolrCategoryServiceImpl.java

示例12: findBlogPosts

import org.alfresco.service.cmr.search.ResultSet; //导入方法依赖的package包/类
@Override
public PagingResults<BlogPostInfo> findBlogPosts(
      final NodeRef blogContainerNode, final RangedDateProperty dateRange, 
      final String tag, final PagingRequest pagingReq)
{
    StringBuilder luceneQuery = new StringBuilder();
    luceneQuery.append("+TYPE:\"").append(ContentModel.TYPE_CONTENT).append("\" ")
               .append("+PARENT:\"").append(blogContainerNode.toString()).append("\" ");
    if (tag != null && !tag.trim().isEmpty())
    {
        luceneQuery.append("+PATH:\"/cm:taggable/cm:").append(ISO9075.encode(tag)).append("/member\"");
    }
    if (dateRange != null)
    {
        luceneQuery.append(createDateRangeQuery(dateRange.getFromDate(), dateRange.getToDate(), dateRange.getDateProperty()));
    }

    SearchParameters sp = new SearchParameters();
    sp.addStore(blogContainerNode.getStoreRef());
    sp.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp.setQuery(luceneQuery.toString());
    sp.addSort(ContentModel.PROP_PUBLISHED.toString(), false);

    sp.setMaxItems(pagingReq.getMaxItems() * MIN_NUMBER_OF_PAGES_FOR_THE_USER_TO_LOOP_THROUGH); 
    sp.setSkipCount(pagingReq.getSkipCount());
    ResultSet luceneResults = null;
    PagingResults<BlogPostInfo> results = null;
    try
    {
        luceneResults = searchService.query(sp);
        final ResultSet finalLuceneResults = luceneResults;
        
        final List<NodeRef> nodeRefs = finalLuceneResults.getNodeRefs().subList(0, min(pagingReq.getMaxItems(), finalLuceneResults.length()));
        
        results = new PagingResults<BlogPostInfo>()
        {
            
            @Override
            public List<BlogPostInfo> getPage()
            {
                List<BlogPostInfo> blogPostInfos = new ArrayList<BlogPostInfo>(nodeRefs.size());
                for (NodeRef nodeRef : nodeRefs)
                {
                    String postName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME); 
                    blogPostInfos.add(new BlogPostInfoImpl(nodeRef, blogContainerNode, postName));
                }
                return blogPostInfos;
            }
            
            @Override
            public String getQueryExecutionId()
            {
                return null;
            }
            
            @Override
            public Pair<Integer, Integer> getTotalResultCount()
            { 
                long totalResultCount = finalLuceneResults.getNumberFound();
                /*if (finalLuceneResults.hasMore()){
                    totalResultCount++;
                }*/ 
                return new Pair<Integer, Integer>((int)totalResultCount, (int)totalResultCount);
            }
            
            @Override
            public boolean hasMoreItems()
            {
                return finalLuceneResults.length() > pagingReq.getMaxItems();
            }
        };
    }
    finally
    {
        if (luceneResults != null) luceneResults.close();
    }
    
    
    return results;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:81,代码来源:BlogServiceImpl.java

示例13: findLinks

import org.alfresco.service.cmr.search.ResultSet; //导入方法依赖的package包/类
@Override
public PagingResults<LinkInfo> findLinks(String siteShortName, String user,
      Date from, Date to, String tag, PagingRequest paging) 
{
   NodeRef container = getSiteLinksContainer(siteShortName, false);
   if (container == null)
   {
      // No links
      return new EmptyPagingResults<LinkInfo>();
   }
   
   // Build the query
   StringBuilder luceneQuery = new StringBuilder();
   luceneQuery.append(" +TYPE:\"" + LinksModel.TYPE_LINK + "\"");
   luceneQuery.append(" +PATH:\"" + nodeService.getPath(container).toPrefixString(namespaceService) + "/*\"");

   if (user != null)
   {
      luceneQuery.append(" [email protected]\\:creator:\"" + user + "\"");
   }
   if (from != null && to != null)
   {
      luceneQuery.append(LuceneUtils.createDateRangeQuery(
            from, to, ContentModel.PROP_CREATED, dictionaryService, namespaceService));
   }
   if (tag != null)
   {
      luceneQuery.append(" +PATH:\"/cm:taggable/cm:" + ISO9075.encode(tag) + "/member\"");
   }
   
   String sortOn = "@{http://www.alfresco.org/model/content/1.0}created";

   // Query
   SearchParameters sp = new SearchParameters();
   sp.addStore(container.getStoreRef());
   sp.setLanguage(SearchService.LANGUAGE_LUCENE);
   sp.setQuery(luceneQuery.toString());
   sp.addSort(sortOn, false);
   if (paging.getSkipCount() > 0)
   {
       sp.setSkipCount(paging.getSkipCount());
   }
   
   
   // Build the results
   PagingResults<LinkInfo> pagedResults = new EmptyPagingResults<LinkInfo>();
   ResultSet results = null;
   
   try 
   {
      results = searchService.query(sp);
      pagedResults = wrap(results, container, paging);
   }
   finally
   {
      if (results != null)
      {
         results.close();
      }
   }
   
   return pagedResults;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:64,代码来源:LinksServiceImpl.java

示例14: query

import org.alfresco.service.cmr.search.ResultSet; //导入方法依赖的package包/类
/**
 * Perform a SearchService query with the given Lucene search string
 */
protected List<TemplateNode> query(String search)
{
    List<TemplateNode> nodes = null;
    HashSet<NodeRef> nodeRefs = new HashSet<NodeRef>();

    // check if a full Lucene search string has been supplied or extracted from XML
    if (search != null && search.length() != 0)
    {
        // perform the search against the repo
        ResultSet results = null;
        try
        {
            results = this.services.getSearchService().query(this.parent.getNodeRef().getStoreRef(),
                    SearchService.LANGUAGE_LUCENE, search);

            if (results.length() != 0)
            {
                NodeService nodeService = this.services.getNodeService();
                
                nodes = new ArrayList<TemplateNode>(results.length());
                for (ResultSetRow row : results)
                {
                    NodeRef nodeRef = row.getNodeRef();
                    if (!nodeRefs.contains(nodeRef) && (nodeService.exists(nodeRef)))
                    {
                        nodes.add(new TemplateNode(nodeRef, services, this.parent.getImageResolver()));
                        nodeRefs.add(nodeRef);
                    }
                }
            }
        }
        catch (Throwable err)
        {
            throw new AlfrescoRuntimeException("Failed to execute search: " + search, err);
        }
        finally
        {
            if (results != null)
            {
                results.close();
            }
        }
    }

    return nodes != null ? nodes : (List) Collections.emptyList();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:50,代码来源:BaseSearchResultsMap.java

示例15: findLinks

import org.alfresco.service.cmr.search.ResultSet; //导入方法依赖的package包/类
public CollectionWithPagingInfo<QuickShareLink> findLinks(Parameters parameters)
{
    checkEnabled();

    String queryString =
            "ASPECT:\"" + QuickShareModel.ASPECT_QSHARE.toString() + "\"";

    SearchParameters sp = new SearchParameters();

    // note: REST API query parameter (ie. where clause filter) - not to be confused with search query ;-)
    Query q = parameters.getQuery();
    if (q != null)
    {
        // filtering via "where" clause
        MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(FIND_SHARED_LINKS_QUERY_PROPERTIES, null);
        QueryHelper.walk(q, propertyWalker);

        String sharedByUserId = propertyWalker.getProperty(PARAM_SHAREDBY, WhereClauseParser.EQUALS, String.class);

        if (sharedByUserId != null)
        {
            if (People.DEFAULT_USER.equalsIgnoreCase(sharedByUserId))
            {
                sharedByUserId =  AuthenticationUtil.getFullyAuthenticatedUser();
            }

            QueryParameterDefinition qpd = new QueryParameterDefImpl(QuickShareModel.PROP_QSHARE_SHAREDBY, dictionaryService.getDataType(DataTypeDefinition.TEXT),
                    true, sharedByUserId);
            sp.addQueryParameterDefinition(qpd);

            String qsharedBy = QuickShareModel.PROP_QSHARE_SHAREDBY.toPrefixString(namespaceService);
            queryString += " [email protected]"+SearchLanguageConversion.escapeLuceneQuery(qsharedBy)+":\"${"+qsharedBy+"}\"";
        }
    }

    sp.setLanguage(SearchService.LANGUAGE_LUCENE);
    sp.setQuery(queryString);
    sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);

    Paging paging = parameters.getPaging();
    PagingRequest pagingRequest = Util.getPagingRequest(paging);

    sp.setSkipCount(pagingRequest.getSkipCount());
    sp.setMaxItems(pagingRequest.getMaxItems());

    sp.addSort("@" + ContentModel.PROP_MODIFIED, false);

    ResultSet results = searchService.query(sp);

    List<QuickShareLink> qsLinks = new ArrayList<>(results.length());

    List<String> includeParam = parameters.getInclude();

    for (ResultSetRow row : results)
    {
        NodeRef nodeRef = row.getNodeRef();
        qsLinks.add(getQuickShareInfo(nodeRef, false, includeParam));
    }

    results.close();

    return CollectionWithPagingInfo.asPaged(paging, qsLinks, results.hasMore(), new Long(results.getNumberFound()).intValue());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:64,代码来源:QuickShareLinksImpl.java


注:本文中的org.alfresco.service.cmr.search.ResultSet.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。