Search in sources :

Example 56 with GetMethod

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

the class YouTrackIntegrationTest method checkSpentTime.

private void checkSpentTime(@NotNull HttpClient client, @NotNull String issueId, @NotNull String expectedTime) throws IOException, JDOMException {
    // Endpoint /rest/issue/BTYT4TT-8/timetracking/workitem/ doesn't work on this instance of YouTrack for some reason
    final GetMethod method = new GetMethod(myRepository.getUrl() + "/rest/issue/" + issueId);
    final int statusCode = client.executeMethod(method);
    assertEquals(HttpStatus.SC_OK, statusCode);
    final Element root = JDOMUtil.load(method.getResponseBodyAsStream());
    for (Element field : root.getChildren("field")) {
        if ("Spent time".equals(field.getAttributeValue("name"))) {
            final Element value = field.getChild("value");
            assertNotNull(value);
            assertEquals(expectedTime, value.getText().trim());
            return;
        }
    }
    fail("Field 'Spent time' not found in issue " + issueId);
}
Also used : Element(org.jdom.Element) GetMethod(org.apache.commons.httpclient.methods.GetMethod)

Example 57 with GetMethod

use of org.apache.commons.httpclient.methods.GetMethod 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 58 with GetMethod

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

the class JiraRestApi method findTasks.

@Override
@NotNull
public final List<Task> findTasks(@NotNull String jql, int max) throws Exception {
    GetMethod method = getMultipleIssuesSearchMethod(jql, max);
    String response = myRepository.executeMethod(method);
    List<JiraIssue> issues = parseIssues(response);
    return ContainerUtil.map(issues, issue -> new JiraRestTask(issue, myRepository));
}
Also used : JiraIssue(com.intellij.tasks.jira.rest.model.JiraIssue) GetMethod(org.apache.commons.httpclient.methods.GetMethod) NotNull(org.jetbrains.annotations.NotNull)

Example 59 with GetMethod

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

the class JiraRestApi2 method getAvailableTaskStates.

@NotNull
@Override
public Set<CustomTaskState> getAvailableTaskStates(@NotNull Task task) throws Exception {
    final GetMethod method = new GetMethod(myRepository.getRestUrl("issue", task.getId(), "transitions"));
    method.setQueryString("expand=transitions.fields");
    final String response = myRepository.executeMethod(method);
    final JiraTransitionsWrapperApi2 wrapper = JiraRepository.GSON.fromJson(response, JiraTransitionsWrapperApi2.class);
    return wrapper.getTransitions();
}
Also used : JiraTransitionsWrapperApi2(com.intellij.tasks.jira.rest.api2.model.JiraTransitionsWrapperApi2) GetMethod(org.apache.commons.httpclient.methods.GetMethod) NotNull(org.jetbrains.annotations.NotNull)

Example 60 with GetMethod

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

the class JiraRestApi2 method getMultipleIssuesSearchMethod.

@NotNull
@Override
protected GetMethod getMultipleIssuesSearchMethod(String jql, int max) {
    GetMethod method = super.getMultipleIssuesSearchMethod(jql, max);
    method.setQueryString(method.getQueryString() + "&fields=" + JiraIssueApi2.REQUIRED_RESPONSE_FIELDS);
    return method;
}
Also used : GetMethod(org.apache.commons.httpclient.methods.GetMethod) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

GetMethod (org.apache.commons.httpclient.methods.GetMethod)357 HttpClient (org.apache.commons.httpclient.HttpClient)216 HttpMethod (org.apache.commons.httpclient.HttpMethod)93 IOException (java.io.IOException)82 Test (org.junit.Test)70 InputStream (java.io.InputStream)65 HttpException (org.apache.commons.httpclient.HttpException)41 Map (java.util.Map)39 ArrayList (java.util.ArrayList)37 HashMap (java.util.HashMap)36 JSONParser (org.json.simple.parser.JSONParser)34 JSONObject (org.json.simple.JSONObject)31 Header (org.apache.commons.httpclient.Header)22 Element (org.w3c.dom.Element)22 PostMethod (org.apache.commons.httpclient.methods.PostMethod)21 TypeToken (com.google.gson.reflect.TypeToken)20 List (java.util.List)19 HttpState (org.apache.commons.httpclient.HttpState)18 URI (java.net.URI)17 JSONArray (org.json.simple.JSONArray)17