Example usage for org.apache.http.impl.client SystemDefaultHttpClient execute

List of usage examples for org.apache.http.impl.client SystemDefaultHttpClient execute

Introduction

In this page you can find the example usage for org.apache.http.impl.client SystemDefaultHttpClient execute.

Prototype

public CloseableHttpResponse execute(final HttpUriRequest request, final HttpContext context)
        throws IOException, ClientProtocolException 

Source Link

Usage

From source file:de.badw.strauss.glyphpicker.controller.alltab.TeiLoadWorker.java

/**
 * Loads TEI data from a URL.//  w  ww .  ja v  a2 s.  co  m
 *
 * @return the resulting GlyphDefinition list
 */
public List<GlyphDefinition> loadDataFromUrl() {
    SystemDefaultHttpClient httpClient = new SystemDefaultHttpClient();
    try {
        HttpGet httpGet = new HttpGet(dataSource.getBasePath());
        return httpClient.execute(httpGet, new XMLResponseHandler());
    } catch (IOException e) {
        String message = String.format(i18n.getString("TeiLoadWorker.couldNotLoadData"),
                e.getLocalizedMessage(), dataSource.getBasePath());
        if (e instanceof UnknownHostException) {
            message += " Unknown host";
        }
        JOptionPane.showMessageDialog(null, message, i18n.getString("TeiLoadWorker.error"),
                JOptionPane.ERROR_MESSAGE);
        LOGGER.info(e);
    } finally {
        httpClient.getConnectionManager().shutdown();
    }

    return null;
}