use of com.github.hakko.musiccabinet.parser.lastfm.UserRecommendedArtistsParser in project musiccabinet by hakko.
the class UserRecommendedArtistsService method updateSearchIndex.
@Override
protected void updateSearchIndex() throws ApplicationException {
List<LastFmUser> users = lastFmSettingsService.getLastFmUsers();
setTotalOperations(users.size());
List<UserRecommendedArtists> artists = new ArrayList<>();
for (LastFmUser user : users) {
try {
WSResponse wsResponse = userRecommendedArtistsClient.getUserRecommendedArtists(user.getLastFmUsername());
LOG.debug(wsResponse);
if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
UserRecommendedArtistsParser parser = new UserRecommendedArtistsParserImpl(stringUtil.getInputStream());
artists.add(new UserRecommendedArtists(user, parser.getArtists()));
}
} catch (ApplicationException e) {
LOG.warn("Fetching top artist for " + user.getLastFmUsername() + " failed.", e);
}
addFinishedOperation();
}
dao.createUserRecommendedArtists(artists);
}
Aggregations