Toggle navigation
Toggle navigation
This project
Loading...
Sign in
grogv3
/
grog-cubi
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jean-Francois Leveque
2017-02-06 10:56:56 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ab477e3e2ec592512937ee15c95ca2a064b5dadf
ab477e3e
1 parent
abce70cb
Ajour d'IndexingException à l'indexation de Publisher.
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
4 deletions
src/main/java/org/legrog/entities/IndexingException.java
src/main/java/org/legrog/entities/PublisherSearchRepository.java
src/main/java/org/legrog/entities/PublisherSearchRepositorySolrj.java
src/main/java/org/legrog/web/publisher/PublisherServiceSpring.java
src/test/java/org/legrog/web/publisher/PublisherServiceSpringTest.java
src/main/java/org/legrog/entities/IndexingException.java
0 → 100644
View file @
ab477e3
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
;
}
}
src/main/java/org/legrog/entities/PublisherSearchRepository.java
View file @
ab477e3
...
...
@@ -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
;
}
...
...
src/main/java/org/legrog/entities/PublisherSearchRepositorySolrj.java
View file @
ab477e3
...
...
@@ -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
.
getMessag
e
());
throw
new
IndexingException
(
sse
.
getRootCaus
e
());
}
return
indexedPublisher
;
...
...
src/main/java/org/legrog/web/publisher/PublisherServiceSpring.java
View file @
ab477e3
...
...
@@ -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
;
}
...
...
src/test/java/org/legrog/web/publisher/PublisherServiceSpringTest.java
View file @
ab477e3
...
...
@@ -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"
);
...
...
Please
register
or
login
to post a comment