use of com.github.hakko.musiccabinet.util.StringUtil in project musiccabinet by hakko.
the class ArtistRelationService method updateSearchIndex.
@Override
protected void updateSearchIndex() throws ApplicationException {
Set<String> artistNames = webserviceHistoryService.getArtistNamesScheduledForUpdate(ARTIST_GET_SIMILAR);
setTotalOperations(artistNames.size());
for (String artistName : artistNames) {
try {
WSResponse wsResponse = artistSimilarityClient.getArtistSimilarity(new Artist(artistName));
if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
ArtistSimilarityParser asParser = new ArtistSimilarityParserImpl(stringUtil.getInputStream());
artistRelationDao.createArtistRelations(asParser.getArtist(), asParser.getArtistRelations());
}
} catch (ApplicationException e) {
LOG.warn("Fetching artist relations for " + artistName + " failed.", e);
}
addFinishedOperation();
}
}
use of com.github.hakko.musiccabinet.util.StringUtil in project musiccabinet by hakko.
the class ArtistTopTracksService method updateSearchIndex.
@Override
protected void updateSearchIndex() throws ApplicationException {
Set<String> artistNames = webserviceHistoryService.getArtistNamesScheduledForUpdate(ARTIST_GET_TOP_TRACKS);
setTotalOperations(artistNames.size());
for (String artistName : artistNames) {
try {
WSResponse wsResponse = artistTopTracksClient.getTopTracks(new Artist(artistName));
if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
ArtistTopTracksParser attParser = new ArtistTopTracksParserImpl(stringUtil.getInputStream());
artistTopTracksDao.createTopTracks(attParser.getArtist(), attParser.getTopTracks());
}
} catch (ApplicationException e) {
LOG.warn("Fetching top tracks for " + artistName + " failed.", e);
}
addFinishedOperation();
}
}
use of com.github.hakko.musiccabinet.util.StringUtil in project musiccabinet by hakko.
the class TagInfoService method updateSearchIndex.
@Override
protected void updateSearchIndex() throws ApplicationException {
List<TagInfo> tagInfos = new ArrayList<>();
Set<String> tags = getTagsForUpdate();
setTotalOperations(tags.size());
for (String tag : tags) {
WSResponse wsResponse = tagInfoClient.getTagInfo(tag, lastFmSettingsService.getLang());
if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
TagInfoParser tiParser = new TagInfoParserImpl(stringUtil.getInputStream());
tagInfos.add(tiParser.getTagInfo());
}
addFinishedOperation();
}
tagInfoDao.createTagInfo(tagInfos);
}
use of com.github.hakko.musiccabinet.util.StringUtil 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