List of usage examples for com.liferay.portal.util HttpImpl proxifyState
@Deprecated public void proxifyState(HttpState httpState, HostConfiguration hostConfiguration)
From source file:com.liferay.portlet.rss.util.RSSWebCacheItem.java
License:Open Source License
public Object convert(String key) throws WebCacheException { SyndFeed feed = null;/* www.ja v a 2 s. com*/ try { // com.liferay.portal.kernel.util.HttpUtil will break the connection // if it spends more than 5 seconds looking up a location. However, // German umlauts do not get encoded correctly. This may be a bug // with commons-httpclient or with how FeedParser uses // java.io.Reader. // Use http://xml.newsisfree.com/feeds/29/629.xml and // http://test.domosoft.com/up/RSS to test if German umlauts show // up correctly. /*Reader reader = new StringReader( new String(HttpUtil.URLtoByteArray(_url))); channel = FeedParser.parse(builder, reader);*/ HttpImpl httpImpl = (HttpImpl) HttpUtil.getHttp(); HostConfiguration hostConfiguration = httpImpl.getHostConfiguration(_url); HttpClient httpClient = httpImpl.getClient(hostConfiguration); httpImpl.proxifyState(httpClient.getState(), hostConfiguration); HttpClientParams httpClientParams = httpClient.getParams(); httpClientParams.setConnectionManagerTimeout(PropsValues.RSS_CONNECTION_TIMEOUT); httpClientParams.setSoTimeout(PropsValues.RSS_CONNECTION_TIMEOUT); GetMethod getMethod = new GetMethod(_url); httpClient.executeMethod(hostConfiguration, getMethod); SyndFeedInput input = new SyndFeedInput(); feed = input.build(new XmlReader(getMethod.getResponseBodyAsStream())); } catch (Exception e) { throw new WebCacheException(_url + " " + e.toString()); } return feed; }