use of eu.europeana.indexing.exception.IndexerRelatedIndexingException in project metis-sandbox by europeana.
the class IndexingServiceImplTest method indexPreview_IndexingIssue_expectFail.
@Test
void indexPreview_IndexingIssue_expectFail() throws IndexingException {
var record = Record.builder().recordId("1").content("".getBytes()).language(Language.IT).country(Country.ITALY).datasetName("").datasetId("").build();
doThrow(new IndexerRelatedIndexingException("Failed")).when(previewIndexer).index(any(InputStream.class), any());
assertThrows(RecordProcessingException.class, () -> service.index(record, IndexEnvironment.PREVIEW));
}
use of eu.europeana.indexing.exception.IndexerRelatedIndexingException in project metis-framework by europeana.
the class FullBeanPublisher method getSolrDocuments.
private SolrDocumentList getSolrDocuments(Map<String, String> queryParamMap) throws IndexerRelatedIndexingException, RecordRelatedIndexingException {
MapSolrParams queryParams = new MapSolrParams(queryParamMap);
QueryResponse response;
try {
response = solrServer.query(queryParams);
} catch (SolrServerException e) {
throw new IndexerRelatedIndexingException(SOLR_SERVER_SEARCH_ERROR, e);
} catch (IOException e) {
throw new RecordRelatedIndexingException(SOLR_SERVER_SEARCH_ERROR, e);
}
return response.getResults();
}
use of eu.europeana.indexing.exception.IndexerRelatedIndexingException in project metis-framework by europeana.
the class IndexerPool method indexRecord.
private void indexRecord(IndexTask indexTask) throws IndexingException {
// Obtain indexer from the pool.
final Indexer indexer;
try {
indexer = pool.borrowObject();
} catch (IndexingException e) {
throw e;
} catch (Exception e) {
throw new IndexerRelatedIndexingException("Error while obtaining indexer from the pool.", e);
}
// Perform indexing and release indexer.
try {
indexTask.performTask(indexer);
} catch (IndexerRelatedIndexingException e) {
invalidateAndSwallowException(indexer);
throw e;
} catch (IndexingException e) {
// If any other indexing exception occurs we want to return the indexer to the pool
pool.returnObject(indexer);
throw e;
}
// Return indexer to the pool if it has not been invalidated.
pool.returnObject(indexer);
}
use of eu.europeana.indexing.exception.IndexerRelatedIndexingException in project metis-sandbox by europeana.
the class IndexingServiceImplTest method indexPublish_IndexingIssue_expectFail.
@Test
void indexPublish_IndexingIssue_expectFail() throws IndexingException {
var record = Record.builder().recordId(1L).content("".getBytes()).language(Language.IT).country(Country.ITALY).datasetName("").datasetId("").build();
doThrow(new IndexerRelatedIndexingException("Failed")).when(publishIndexer).index(any(InputStream.class), any());
assertThrows(RecordProcessingException.class, () -> service.index(record));
}
use of eu.europeana.indexing.exception.IndexerRelatedIndexingException in project metis-sandbox by europeana.
the class IndexingServiceImplTest method remove_indexingException_expectFail.
@Test
void remove_indexingException_expectFail() throws IndexingException {
when(publishIndexer.removeAll("1", null)).thenThrow(new IndexerRelatedIndexingException("failed"));
assertThrows(DatasetIndexRemoveException.class, () -> service.remove("1"));
}
Aggregations