use of org.alfresco.repo.search.QueryParameterDefImpl in project acs-community-packaging by Alfresco.
the class AbstractClipboardItem method checkExists.
protected boolean checkExists(String name, NodeRef parent) {
QueryParameterDefinition[] params = new QueryParameterDefinition[1];
params[0] = new QueryParameterDefImpl(ContentModel.PROP_NAME, getServiceRegistry().getDictionaryService().getDataType(DataTypeDefinition.TEXT), true, name);
// execute the query
List<NodeRef> nodeRefs = getServiceRegistry().getSearchService().selectNodes(parent, XPATH_QUERY_NODE_MATCH, params, getServiceRegistry().getNamespaceService(), false);
return (nodeRefs.size() != 0);
}
use of org.alfresco.repo.search.QueryParameterDefImpl in project alfresco-remote-api by Alfresco.
the class QuickShareLinksImpl method findLinks.
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 += " +@" + 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(), Long.valueOf(results.getNumberFound()).intValue());
}
Aggregations