Search in sources :

Example 16 with HttpMethod

use of org.apache.commons.httpclient.HttpMethod in project zm-mailbox by Zimbra.

the class ElasticSearchIndexTest method indexStoreAvailable.

@Override
protected boolean indexStoreAvailable() {
    String indexUrl = String.format("%s?_status", LC.zimbra_index_elasticsearch_url_base.value());
    HttpMethod method = new GetMethod(indexUrl);
    try {
        ElasticSearchConnector connector = new ElasticSearchConnector();
        connector.executeMethod(method);
    } catch (HttpException e) {
        ZimbraLog.index.error("Problem accessing the ElasticSearch Index store", e);
        return false;
    } catch (IOException e) {
        ZimbraLog.index.error("Problem accessing the ElasticSearch Index store", e);
        return false;
    }
    return true;
}
Also used : ElasticSearchConnector(com.zimbra.cs.index.elasticsearch.ElasticSearchConnector) GetMethod(org.apache.commons.httpclient.methods.GetMethod) HttpException(org.apache.commons.httpclient.HttpException) IOException(java.io.IOException) HttpMethod(org.apache.commons.httpclient.HttpMethod)

Example 17 with HttpMethod

use of org.apache.commons.httpclient.HttpMethod in project intellij-community by JetBrains.

the class GenericRepository method getHttpMethod.

private HttpMethod getHttpMethod(String requestUrl, HTTPMethod type) {
    HttpMethod method = type == HTTPMethod.GET ? new GetMethod(requestUrl) : GenericRepositoryUtil.getPostMethodFromURL(requestUrl);
    configureHttpMethod(method);
    return method;
}
Also used : GetMethod(org.apache.commons.httpclient.methods.GetMethod) HttpMethod(org.apache.commons.httpclient.HttpMethod)

Example 18 with HttpMethod

use of org.apache.commons.httpclient.HttpMethod in project intellij-community by JetBrains.

the class LighthouseRepository method doREST.

private HttpMethod doREST(String request, boolean post, HttpClient client) throws Exception {
    String uri = getUrl() + request;
    HttpMethod method = post ? new PostMethod(uri) : new GetMethod(uri);
    configureHttpMethod(method);
    client.executeMethod(method);
    return method;
}
Also used : PostMethod(org.apache.commons.httpclient.methods.PostMethod) GetMethod(org.apache.commons.httpclient.methods.GetMethod) HttpMethod(org.apache.commons.httpclient.HttpMethod)

Example 19 with HttpMethod

use of org.apache.commons.httpclient.HttpMethod in project intellij-community by JetBrains.

the class PivotalTrackerRepository method findTask.

@Nullable
@Override
public Task findTask(@NotNull final String id) throws Exception {
    final String realId = getRealId(id);
    if (realId == null)
        return null;
    final String url = API_URL + "/projects/" + myProjectId + "/stories/" + realId;
    LOG.info("Retrieving issue by id: " + url);
    final HttpMethod method = doREST(url, HTTPMethod.GET);
    final InputStream stream = method.getResponseBodyAsStream();
    final Element element = new SAXBuilder(false).build(stream).getRootElement();
    return element.getName().equals("story") ? createIssue(element) : null;
}
Also used : SAXBuilder(org.jdom.input.SAXBuilder) InputStream(java.io.InputStream) Element(org.jdom.Element) HttpMethod(org.apache.commons.httpclient.HttpMethod) Nullable(org.jetbrains.annotations.Nullable)

Example 20 with HttpMethod

use of org.apache.commons.httpclient.HttpMethod in project CloudStack-archive by CloudStack-extras.

the class StressTestDirectAttach method executeEventsAndBilling.

private static int executeEventsAndBilling(String server, String developerServer) throws HttpException, IOException {
    // test steps:
    // - get all the events in the system for all users in the system
    // - generate all the usage records in the system
    // - get all the usage records in the system
    // -----------------------------
    // GET EVENTS
    // -----------------------------
    String url = server + "?command=listEvents&page=1&account=" + _account.get();
    s_logger.info("Getting events for the account " + _account.get());
    HttpClient client = new HttpClient();
    HttpMethod method = new GetMethod(url);
    int responseCode = client.executeMethod(method);
    s_logger.info("get events response code: " + responseCode);
    if (responseCode == 200) {
        InputStream is = method.getResponseBodyAsStream();
        Map<String, List<String>> eventDescriptions = getMultipleValuesFromXML(is, new String[] { "description" });
        List<String> descriptionText = eventDescriptions.get("description");
        if (descriptionText == null) {
            s_logger.info("no events retrieved...");
        } else {
            for (String text : descriptionText) {
                s_logger.info("event: " + text);
            }
        }
    } else {
        s_logger.error("list events failed with error code: " + responseCode + ". Following URL was sent: " + url);
        return responseCode;
    }
    return responseCode;
}
Also used : InputStream(java.io.InputStream) HttpClient(org.apache.commons.httpclient.HttpClient) GetMethod(org.apache.commons.httpclient.methods.GetMethod) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List) HttpMethod(org.apache.commons.httpclient.HttpMethod)

Aggregations

HttpMethod (org.apache.commons.httpclient.HttpMethod)151 HttpClient (org.apache.commons.httpclient.HttpClient)99 GetMethod (org.apache.commons.httpclient.methods.GetMethod)95 InputStream (java.io.InputStream)61 IOException (java.io.IOException)43 ArrayList (java.util.ArrayList)30 HttpException (org.apache.commons.httpclient.HttpException)28 Map (java.util.Map)24 Test (org.junit.Test)23 Element (org.w3c.dom.Element)22 HashMap (java.util.HashMap)20 PostMethod (org.apache.commons.httpclient.methods.PostMethod)19 Header (org.apache.commons.httpclient.Header)17 List (java.util.List)14 NameValuePair (org.apache.commons.httpclient.NameValuePair)13 NodeList (org.w3c.dom.NodeList)12 FileInputStream (java.io.FileInputStream)10 HttpTest (org.apache.sling.commons.testing.integration.HttpTest)10 SAXBuilder (org.jdom.input.SAXBuilder)10 UsernamePasswordCredentials (org.apache.commons.httpclient.UsernamePasswordCredentials)9