Jean-Francois Leveque

Ajour d'IndexingException à l'indexation de Publisher.

package org.legrog.entities;
import javax.ejb.ApplicationException;
/*
Exception when indexing fails, whatever the reason. Has to be dealt with at service level.
*/
@ApplicationException(rollback = true)
public class IndexingException extends Exception {
Throwable rootCause;
IndexingException(Throwable rootCause) {
this.rootCause = rootCause;
}
public Throwable getRootCause() {
return rootCause;
}
}
......@@ -15,5 +15,5 @@ public interface PublisherSearchRepository /*extends SolrCrudRepository<IndexedP
Indexe la version simplifiée de Publisher, IndexedPublisher.
*/
public IndexedPublisher save(IndexedPublisher indexedPublisher);
public IndexedPublisher save(IndexedPublisher indexedPublisher) throws IndexingException;
}
......
......@@ -27,14 +27,14 @@ public class PublisherSearchRepositorySolrj implements PublisherSearchRepository
}
@Override
public IndexedPublisher save(IndexedPublisher indexedPublisher) {
public IndexedPublisher save(IndexedPublisher indexedPublisher) throws IndexingException {
try {
UpdateResponse updateResponse = solrClient.addBean(indexedPublisher, 1);
logger.trace("validatePublisherVersion SolrJ UpdateResponse {}", updateResponse);
} catch (IOException ioe) {
logger.error("validatePublisherVersion IOException {}", ioe.getMessage());
throw new IndexingException(ioe);
} catch (SolrServerException sse) {
logger.error("validatePublisherVersion SolrServerException {}", sse.getMessage());
throw new IndexingException(sse.getRootCause());
}
return indexedPublisher;
......
......@@ -83,7 +83,11 @@ public class PublisherServiceSpring implements PublisherService {
publisherAction.setPublisher(publisher);
this.savePublisher(publisher);
IndexedPublisher indexedPublisher = new IndexedPublisher(publisher);
try {
publisherSearchRepository.save(indexedPublisher);
} catch (IndexingException e) {
}
publisherActionRepository.save(publisherAction);
return publisherAction;
}
......
......@@ -109,7 +109,11 @@ public class PublisherServiceSpringTest {
when(publisherVersionMock.getPublisherName()).thenReturn("nom");
when(publisherVersionMock.getPublisherHistory()).thenReturn("histoire");
publisherServiceSpring.validatePublisherVersion(publisherVersionMock);
try {
Mockito.verify(publisherSearchRepository).save(indexedPublisherArgumentCaptor.capture());
} catch (IndexingException e) {
e.printStackTrace();
}
IndexedPublisher indexedPublisher = indexedPublisherArgumentCaptor.getValue();
assertThat(indexedPublisher.getPublisherId()).isEqualTo(111);
assertThat(indexedPublisher.getPublisherName()).isEqualTo("nom");
......