Package com.github.hakko.musiccabinet.exception

Examples of com.github.hakko.musiccabinet.exception.ApplicationException


  public void handlesArtistFailureDuringUpdate() throws ApplicationException {
    final String revName = reverse(artistName);
    submitFile(additionDao, getFile(revName, albumName, trackName));
   
    Mockito.when(service.artistQueryClient.get(revName)).thenThrow(
      new ApplicationException("Fail", new HttpResponseException(503, "Overloaded")));
   
    service.updateDiscography();
   
    List<MBAlbum> albums = service.getMissingAlbums(artistName, asList(TYPE_EP), null, -1, 0);
    Assert.assertEquals(2, albums.size());
View Full Code Here


    public void updateSearchIndex() throws ApplicationException {
      setTotalOperations(TOTAL_CALCULATIONS);
      for (int i = 0; i < TOTAL_CALCULATIONS; i++) {
        // real work would go here
        if (i == FAIL_INDEX) {
          throw new ApplicationException("Failing at index " + FAIL_INDEX);
        }
        addFinishedOperation();
      }
    }
View Full Code Here

   *
   * Otherwise, a general ApplicationException is thrown.
   */
  private void validateResponse() throws ApplicationException {
    if (responseBody == null || responseBody.isEmpty()) {
      throw new ApplicationException(
          "The response from Last.fm did not contain any data!");
    }
    if (responseBody.indexOf(RESPONSE_OK) != -1) {
      callSuccessful = true;
      return;
    }
    if (responseBody.indexOf(RESPONSE_FAILED) != -1) {
      parseErrorCodeAndMessage();
    } else {
      throw new ApplicationException(
          "The response from Last.fm wasn't wrapped as promised!");
    }
  }
View Full Code Here

      }
    }
   
    if (errorCodeStart * errorCodeEnd * errorMsgStart * errorMsgEnd == 0) {
      LOG.info(responseBody);
      throw new ApplicationException("Response from Last.fm not properly formed!");
    }
   
    errorCode = toInt(responseBody.substring(errorCodeStart, errorCodeEnd));
    errorMessage = responseBody.substring(errorMsgStart, errorMsgEnd);
    errorRecoverable = isLastfmRecoverable(errorCode);
View Full Code Here

      elapsedMs += currentTimeMillis();
      sleep(Math.max(INTERVAL_MS - elapsedMs, 0));
    } catch (HttpResponseException e) {
      LOG.warn(format("MusicBrainz internal error: %d, %s",
          e.getStatusCode(), e.getMessage()));
      throw new ApplicationException("MusicBrainz internal error!", e);
    } catch (IOException e) {
      throw new ApplicationException("MusicBrainz communication failed!", e);
    } catch (InterruptedException e) {
      LOG.warn("MusicBrainz sleep interrupted!", e);
    }
        webserviceHistoryService.logWebserviceInvocation(invocation);
        return response;
View Full Code Here

      for (NameValuePair param : params) {
        uriBuilder.addParameter(param.getName(), param.getValue());
      }
      uri = uriBuilder.build();
    } catch (URISyntaxException e) {
      throw new ApplicationException("Could not create MusicBrainz URI!", e);
    }
    return uri;
  }
View Full Code Here

    try {
      MessageDigest md = MessageDigest.getInstance("md5");
      params.add(new BasicNameValuePair(PARAM_API_SIG, new String(
          encodeHex(md.digest(sb.toString().getBytes(UTF8))))));
    } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
      throw new ApplicationException("Can not make authenticated call!", e);
    }
  }
View Full Code Here

      for (NameValuePair param : params) {
        uriBuilder.addParameter(param.getName(), param.getValue());
      }
      uri = uriBuilder.build();
    } catch (URISyntaxException e) {
      throw new ApplicationException("Could not create Last.fm URI!", e);
    }
    return uri;
  }
View Full Code Here

  throws ApplicationException {
    try (InputStream autoClosingStream = source) {
      SAXParser saxParser = getSAXParser();
      saxParser.parse(source, handler);
    } catch (IOException e) {
      throw new ApplicationException("Could not read data from stream!", e);
    } catch (SAXException e) {
      throw new ApplicationException("Could not parse data from stream!", e);
    } catch (ParserConfigurationException e) {
      throw new ApplicationException("Could not set up SAX parser!", e);
    }
  }
View Full Code Here

  protected synchronized XMLEventReader getXMLEventReader(InputStream source) throws ApplicationException {
    XMLEventReader eventReader;
    try {
      eventReader = xmlInputFactory.createXMLEventReader(source);
    } catch (XMLStreamException e) {
      throw new ApplicationException("Could not read input data!", e);
    }
    return eventReader;
  }
View Full Code Here

TOP

Related Classes of com.github.hakko.musiccabinet.exception.ApplicationException

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.