use of com.github.hakko.musiccabinet.domain.model.aggr.ArtistUserTag in project musiccabinet by hakko.
the class TagUpdateClientTest method validateParametersForAddingTag.
@Test
public void validateParametersForAddingTag() throws ApplicationException {
final ArtistUserTag artistUserTagAdd = new ArtistUserTag(artist, lastFmUser, tag, 100, true);
new TagUpdateClient() {
@Override
protected WSResponse executeWSRequest(List<NameValuePair> params) throws ApplicationException {
assertHasParameter(params, PARAM_METHOD, ADD_METHOD);
assertHasParameter(params, PARAM_ARTIST, artist.getName());
assertHasParameter(params, PARAM_TAGS, "pop");
assertHasParameter(params, PARAM_SK, lastFmUser.getSessionKey());
return null;
}
}.updateTag(artistUserTagAdd);
}
use of com.github.hakko.musiccabinet.domain.model.aggr.ArtistUserTag in project musiccabinet by hakko.
the class TagUpdateClientTest method validateParametersForRemovingTag.
@Test
public void validateParametersForRemovingTag() throws ApplicationException {
final ArtistUserTag artistUserTagRemove = new ArtistUserTag(artist, lastFmUser, tag, 10, false);
new TagUpdateClient() {
@Override
protected WSResponse executeWSRequest(List<NameValuePair> params) throws ApplicationException {
assertHasParameter(params, PARAM_METHOD, REMOVE_METHOD);
assertHasParameter(params, PARAM_ARTIST, artist.getName());
assertHasParameter(params, PARAM_TAG, "pop");
assertHasParameter(params, PARAM_SK, lastFmUser.getSessionKey());
return null;
}
}.updateTag(artistUserTagRemove);
}
use of com.github.hakko.musiccabinet.domain.model.aggr.ArtistUserTag in project musiccabinet by hakko.
the class TagUpdateService method updateTags.
protected void updateTags() throws ApplicationException {
resendFailedUpdates();
ArtistUserTag aut;
while (failedUpdates.isEmpty() && (aut = artistUserTags.poll()) != null) {
if ((aut.isIncrease() && aut.getTagCount() >= MAX_THRESHOLD) || (!aut.isIncrease() && aut.getTagCount() <= MIN_THRESHOLD)) {
WSResponse wsResponse = tagUpdateClient.updateTag(aut);
if (!wsResponse.wasCallSuccessful()) {
LOG.warn("updating " + aut + " failed! Add for re-sending.");
LOG.debug("Response: " + wsResponse);
failedUpdates.add(aut);
}
}
}
}
use of com.github.hakko.musiccabinet.domain.model.aggr.ArtistUserTag in project musiccabinet by hakko.
the class TagUpdateService method resendFailedUpdates.
protected void resendFailedUpdates() throws ApplicationException {
while (failedUpdates.size() > 0) {
LOG.debug("Queue of failed updates consists of " + failedUpdates.size() + " elements.");
ArtistUserTag firstFailed = failedUpdates.get(0);
WSResponse wsResponse = tagUpdateClient.updateTag(firstFailed);
if (wsResponse.wasCallSuccessful()) {
LOG.debug("Failed tag update was re-sent.");
failedUpdates.remove(0);
} else {
LOG.debug("Failed tag update could not be re-sent. Wait a minute before trying again.");
LOG.debug("Response: " + wsResponse);
return;
}
}
}
use of com.github.hakko.musiccabinet.domain.model.aggr.ArtistUserTag in project musiccabinet by hakko.
the class TagUpdateService method register.
protected void register(ArtistUserTag submission) {
for (Iterator<ArtistUserTag> it = artistUserTags.iterator(); it.hasNext(); ) {
ArtistUserTag aut = it.next();
if (aut.getArtist().getId() == submission.getArtist().getId() && aut.getTagName().equals(submission.getTagName()) && aut.getLastFmUser().getId() == submission.getLastFmUser().getId()) {
it.remove();
LOG.debug("remove " + aut + ", in favor of " + submission);
}
}
artistUserTags.add(submission);
webserviceHistoryService.blockWebserviceInvocation(submission.getArtist().getId(), ARTIST_GET_TOP_TAGS);
artistTopTagsDao.updateTopTag(submission.getArtist().getId(), submission.getTagName(), submission.getTagCount());
}
Aggregations