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;
}
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);
}
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);
}
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);
}
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;
}
Aggregations