*/
private FeedIF retrieveFeed(String uri) throws FeedManagerException {
try {
URL urlToRetrieve = new URL(uri);
URLConnection conn = null;
try {
conn = urlToRetrieve.openConnection();
if (conn instanceof HttpURLConnection) {
HttpURLConnection httpConn = (HttpURLConnection) conn;
httpConn.setInstanceFollowRedirects(true); // not needed, default ?
// Hack for User-Agent : problem for
// http://www.diveintomark.org/xml/rss.xml
HttpHeaderUtils.setUserAgent(httpConn, "Informa Java API");
logger.debug("retr feed at url " + uri + ": ETag"
+ HttpHeaderUtils.getETagValue(httpConn) + " if-modified :"
+ HttpHeaderUtils.getLastModified(httpConn));
// get initial values for cond. GET in updateChannel
this.httpHeaders.setETag(HttpHeaderUtils.getETagValue(httpConn));
this.httpHeaders.setIfModifiedSince(HttpHeaderUtils
.getLastModified(httpConn));
}
} catch (java.lang.ClassCastException e) {
conn = null;
logger.warn("problem cast to HttpURLConnection " + uri, e);
throw new FeedManagerException(e);
} catch (NullPointerException e) {
logger.error("problem NPE " + uri + " conn=" + conn, e);
conn = null;
throw new FeedManagerException(e);
}
ChannelIF channel = null;
/*
* if ( conn == null ) { channel = FeedParser.parse(getChannelBuilder(),
* uri); } else {
*/
channel = FeedParser.parse(getChannelBuilder(), conn.getInputStream());
//}
this.timeToExpire = getTimeToExpire(channel);
this.feed = new Feed(channel);