private static HttpURLConnection getConnection(URL url, Model model)
throws IOException {
int responseCode = 300;
HttpURLConnection connection = null;
while ((responseCode >= 300) && (responseCode < 400)) {
HttpURLTools urlTools = new HttpURLTools(url);
urlTools
.setAccept("text/rdf+xml, application/rdf+xml, text/rss+xml, application/rss+xml, application/xml, application/xml");
// set accept-language
urlTools.setAcceptLanguage(getAcceptLanguages(model));
HttpURLConnection.setFollowRedirects(true);
connection = (HttpURLConnection) urlTools.getConnection();
responseCode = connection.getResponseCode();
if ((responseCode < 300) || (responseCode >= 400)) {
break;
}
url = new URL(connection.getHeaderField("Location"));