public Appcast fetch(String url) throws AppcastException {
WebTarget appcastResource = client.target(url);
Response response = appcastResource.request(MediaType.APPLICATION_XML_TYPE).get(Response.class);
if (response == null) {
logger.log(Level.SEVERE, "Could not fetch appcast from URL ''{0}''", url);
throw new AppcastException("Could not fetch appcast from URL", url, 500, null);
}
if (response.getStatus() != Status.OK.getStatusCode()) {
logger.log(Level.SEVERE, "Could not fetch appcast from URL ''{0}'': {1} {2}", new Object[]{url, response.getStatus(), response.getStatusInfo()});
throw new AppcastException("Could not fetch appcast from URL", url, response.getStatus(), response.getStatusInfo().getReasonPhrase());
}
// Got a valid response
return response.readEntity(Appcast.class);
}