use of org.xwiki.search.solr.internal.api.SolrInstance in project xwiki-platform by xwiki.
the class SolrInstanceProviderTest method testRemoteInstanceRetrieval.
@Test
public void testRemoteInstanceRetrieval() throws Exception {
when(this.mockConfig.getServerType()).thenReturn("remote");
SolrInstance instance = this.mocker.getComponentUnderTest().get();
Assert.assertNotNull(instance);
Assert.assertSame(this.remote, instance);
}
use of org.xwiki.search.solr.internal.api.SolrInstance in project xwiki-platform by xwiki.
the class DefaultSolrIndexer method commit.
/**
* Commit.
*/
private void commit() {
SolrInstance solrInstance = this.solrInstanceProvider.get();
try {
solrInstance.commit();
} catch (Exception e) {
this.logger.error("Failed to commit index changes to the Solr server. Rolling back.", e);
try {
solrInstance.rollback();
} catch (Exception ex) {
// Just log the failure.
this.logger.error("Failed to rollback index changes.", ex);
}
}
this.batchSize = 0;
}
use of org.xwiki.search.solr.internal.api.SolrInstance in project xwiki-platform by xwiki.
the class SolrQueryExecutor method execute.
@Override
public <T> List<T> execute(Query query) throws QueryException {
this.progress.startStep(query, "query.solr.progress.execute", "Execute Solr query [{}]", query);
this.progress.pushLevelProgress(3, query);
try {
this.progress.startStep(query, "query.solr.progress.execute.prepare", "Prepare");
SolrInstance solrInstance = solrInstanceProvider.get();
SolrQuery solrQuery = createSolrQuery(query);
this.progress.startStep(query, "query.solr.progress.execute.execute", "Execute");
QueryResponse response = solrInstance.query(solrQuery);
this.progress.startStep(query, "query.solr.progress.execute.filter", "Filter");
// Check access rights need to be checked before returning the response.
// FIXME: this is not really the best way, mostly because at this point all grouping operations
// have already been performed and any change on the result will not ensure that the grouping
// information (facets, highlighting, maxScore, etc.) is still relevant.
// A better way would be using a PostFilter as described in this article:
// http://java.dzone.com/articles/custom-security-filtering-solr
// Basically, we would be asking
List<DocumentReference> usersToCheck = new ArrayList<>(2);
if (query instanceof SecureQuery) {
if (((SecureQuery) query).isCurrentUserChecked()) {
usersToCheck.add(xcontextProvider.get().getUserReference());
}
if (((SecureQuery) query).isCurrentAuthorChecked()) {
usersToCheck.add(xcontextProvider.get().getAuthorReference());
}
} else {
usersToCheck.add(xcontextProvider.get().getUserReference());
usersToCheck.add(xcontextProvider.get().getAuthorReference());
}
if (!usersToCheck.isEmpty()) {
filterResponse(response, usersToCheck);
}
return (List<T>) Arrays.asList(response);
} catch (Exception e) {
throw new QueryException("Exception while executing query", query, e);
} finally {
this.progress.popLevelProgress(query);
this.progress.endStep(query);
}
}
Aggregations