use of com.github.hakko.musiccabinet.parser.lastfm.TagTopArtistsParser in project musiccabinet by hakko.
the class TagTopArtistsService method updateSearchIndex.
@Override
protected void updateSearchIndex() throws ApplicationException {
List<TagTopArtists> topArtists = new ArrayList<>();
List<Tag> tags = tagDao.getTagsWithoutTopArtists();
setTotalOperations(tags.size());
for (Tag tag : tags) {
try {
WSResponse wsResponse = tagTopArtistsClient.getTopArtists(tag);
if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
TagTopArtistsParser parser = new TagTopArtistsParserImpl(stringUtil.getInputStream());
topArtists.add(new TagTopArtists(tag.getName(), parser.getArtists()));
}
} catch (ApplicationException e) {
LOG.warn("Fetching top artist for " + tag.getName() + " failed.", e);
}
addFinishedOperation();
}
tagDao.createTopArtists(topArtists);
}
Aggregations