Package com.github.hakko.musiccabinet.ws.lastfm

Examples of com.github.hakko.musiccabinet.ws.lastfm.WSResponse


  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);
View Full Code Here


   
    setTotalOperations(artistNames.size());
   
    for (String artistName : artistNames) {
      try {
        WSResponse wsResponse = artistTopTagsClient.getTopTags(new Artist(artistName));
        if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
          StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
          ArtistTopTagsParser attParser =
            new ArtistTopTagsParserImpl(stringUtil.getInputStream());
          removeTagsWithLowTagCount(attParser.getTopTags());
          artistTopTagsDao.createTopTags(attParser.getArtist(),
              attParser.getTopTags());
View Full Code Here

  @Override
  protected void updateSearchIndex() throws ApplicationException {
    short page = 0, totalPages = 0;
    do {
      WSResponse wsResponse = client.getLibraryTracks(page,
          lastFmSettingsService.getLastFmUsername());
      if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
        StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
        ScrobbledTracksParser parser = new ScrobbledTracksParserImpl(
            stringUtil.getInputStream());
        totalPages = parser.getTotalPages();
        trackPlayCountDao.createTrackPlayCounts(parser.getTrackPlayCounts());
        setTotalOperations(totalPages);
View Full Code Here

    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();
    }
View Full Code Here

  private static final Logger LOG = Logger.getLogger(LastFmService.class);

  public LastFmUser identifyLastFmUser(String token) throws ApplicationException {
    LOG.debug("identifyLastFmUser(" + token + ")");
    WSResponse wsResponse = authSessionClient.getAuthSession(token);
    if (wsResponse.wasCallAllowed() && wsResponse.wasCallSuccessful()) {
      StringUtil stringUtil = new StringUtil(wsResponse.getResponseBody());
      AuthSessionParser authSessionParser =
          new AuthSessionParserImpl(stringUtil.getInputStream());
      return authSessionParser.getLastFmUser();
    } else {
      LOG.debug("wsResponse: " + wsResponse.getResponseBody());
      throw new ApplicationException("Could not get session key for user! (code "
          + wsResponse.getErrorCode() + ", " + wsResponse.getErrorMessage() + ")");
    }
  }
View Full Code Here

TOP

Related Classes of com.github.hakko.musiccabinet.ws.lastfm.WSResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.