Java 类com.intellij.util.net.HTTPMethod 实例源码

项目:intellij-ce-playground    文件:PivotalTrackerRepository.java   
private List<Element> getStories(@Nullable final String query, final int max) throws Exception {
  String url = API_URL + "/projects/" + myProjectId + "/stories";
  url += "?filter=" + encodeUrl("state:started,unstarted,unscheduled,rejected");
  if (!StringUtil.isEmpty(query)) {
    url += encodeUrl(" \"" + query + '"');
  }
  if (max >= 0) {
    url += "&limit=" + encodeUrl(String.valueOf(max));
  }
  LOG.info("Getting all the stories with url: " + url);
  final HttpMethod method = doREST(url, HTTPMethod.GET);
  final InputStream stream = method.getResponseBodyAsStream();
  final Element element = new SAXBuilder(false).build(stream).getRootElement();

  if (!"stories".equals(element.getName())) {
    LOG.warn("Error fetching issues for: " + url + ", HTTP status code: " + method.getStatusCode());
    throw new Exception("Error fetching issues for: " + url + ", HTTP status code: " + method.getStatusCode() +
                        "\n" + element.getText());
  }

  return element.getChildren("story");
}
项目:r2m-plugin-android    文件:MethodTypeSection.java   
public void selectVerb(HTTPMethod verb) {
    switch (verb) {
        case GET:
            buttonGETRequest.setSelected(true);
            requestPayloadSection.setVisible(false);
            requestPayloadSection.clearPayload();
            break;
        case POST:
            buttonPOSTRequest.setSelected(true);
            requestPayloadSection.setVisible(true);
            break;
        case DELETE:
            buttonDELETERequest.setSelected(true);
            requestPayloadSection.setVisible(true);
            break;
        case PUT:
            buttonPUTRequest.setSelected(true);
            requestPayloadSection.setVisible(true);
            break;
        default:
            throw new IllegalArgumentException("unsupported method " + verb);
    }
    httpMethod = verb;

}
项目:tools-idea    文件:PivotalTrackerRepository.java   
private List<Element> getStories(@Nullable final String query, final int max) throws Exception {
  String url = API_URL + "/projects/" + myProjectId + "/stories";
  url += "?filter=" + encodeUrl("state:started,unstarted,unscheduled,rejected");
  if (!StringUtil.isEmpty(query)) {
    url += encodeUrl(" \"" + query + '"');
  }
  if (max >= 0) {
    url += "&limit=" + encodeUrl(String.valueOf(max));
  }
  LOG.info("Getting all the stories with url: " + url);
  final HttpMethod method = doREST(url, HTTPMethod.GET);
  final InputStream stream = method.getResponseBodyAsStream();
  final Element element = new SAXBuilder(false).build(stream).getRootElement();

  if (!"stories".equals(element.getName())) {
    LOG.warn("Error fetching issues for: " + url + ", HTTP status code: " + method.getStatusCode());
    throw new Exception("Error fetching issues for: " + url + ", HTTP status code: " + method.getStatusCode() +
                        "\n" + element.getText());
  }

  return element.getChildren("story");
}
项目:tools-idea    文件:PivotalTrackerRepository.java   
@Override
public void setTaskState(Task task, TaskState state) throws Exception {
  if (state != TaskState.IN_PROGRESS) super.setTaskState(task, state);
  final String realId = getRealId(task.getId());
  if (realId == null) return;
  String url = API_URL + "/projects/" + myProjectId + "/stories/" + realId;
  url +="?" + encodeUrl("story[current_state]") + "=" + encodeUrl("started");
  LOG.info("Updating issue state by id: " + url);
  final HttpMethod method = doREST(url, HTTPMethod.PUT);
  final InputStream stream = method.getResponseBodyAsStream();
  final Element element = new SAXBuilder(false).build(stream).getRootElement();
  final Task story = element.getName().equals("story") ? createIssue(element) : null;
  if (story == null) {
    throw new Exception("Error setting state for: " + url + ", HTTP status code: " + method.getStatusCode() +
                              "\n" + element.getText());
  }
}
项目:consulo-tasks    文件:PivotalTrackerRepository.java   
private List<Element> getStories(@Nullable final String query, final int max) throws Exception {
  String url = API_URL + "/projects/" + myProjectId + "/stories";
  url += "?filter=" + encodeUrl("state:started,unstarted,unscheduled,rejected");
  if (!StringUtil.isEmpty(query)) {
    url += encodeUrl(" \"" + query + '"');
  }
  if (max >= 0) {
    url += "&limit=" + encodeUrl(String.valueOf(max));
  }
  LOG.info("Getting all the stories with url: " + url);
  final HttpMethod method = doREST(url, HTTPMethod.GET);
  final InputStream stream = method.getResponseBodyAsStream();
  final Element element = new SAXBuilder(false).build(stream).getRootElement();

  if (!"stories".equals(element.getName())) {
    LOG.warn("Error fetching issues for: " + url + ", HTTP status code: " + method.getStatusCode());
    throw new Exception("Error fetching issues for: " + url + ", HTTP status code: " + method.getStatusCode() +
                        "\n" + element.getText());
  }

  return element.getChildren("story");
}
项目:consulo-tasks    文件:PivotalTrackerRepository.java   
@Override
public void setTaskState(Task task, TaskState state) throws Exception {
  if (state != TaskState.IN_PROGRESS) super.setTaskState(task, state);
  final String realId = getRealId(task.getId());
  if (realId == null) return;
  String url = API_URL + "/projects/" + myProjectId + "/stories/" + realId;
  url +="?" + encodeUrl("story[current_state]") + "=" + encodeUrl("started");
  LOG.info("Updating issue state by id: " + url);
  final HttpMethod method = doREST(url, HTTPMethod.PUT);
  final InputStream stream = method.getResponseBodyAsStream();
  final Element element = new SAXBuilder(false).build(stream).getRootElement();
  final Task story = element.getName().equals("story") ? createIssue(element) : null;
  if (story == null) {
    throw new Exception("Error setting state for: " + url + ", HTTP status code: " + method.getStatusCode() +
                              "\n" + element.getText());
  }
}
项目:intellij-swagger    文件:SwaggerCompletionTest.java   
@Test
public void testHttpOperations() {
    //see swagger spec, all but 'trace' operations are supported
    Collection<String> allButTrace = Arrays.stream(HTTPMethod.values())
            .filter(m -> m != HTTPMethod.TRACE)
            .map(HTTPMethod::name)
            .map(String::toLowerCase)
            .sorted()
            .collect(Collectors.toList());

    getCaretCompletions("http_operations")
            .assertContains(allButTrace)
            .assertContains("$ref")
            .assertNotContains("trace");
}
项目:intellij-ce-playground    文件:GenericRepository.java   
public void resetToDefaults() {
  myLoginURL = "";
  myTasksListUrl = "";
  mySingleTaskUrl = "";
  myDownloadTasksInSeparateRequests = false;
  myLoginMethodType = HTTPMethod.GET;
  myTasksListMethodType = HTTPMethod.GET;
  mySingleTaskMethodType = HTTPMethod.GET;
  myResponseType = ResponseType.XML;
  myTemplateVariables = new ArrayList<TemplateVariable>();
  myResponseHandlersMap = new EnumMap<ResponseType, ResponseHandler>(ResponseType.class);
  myResponseHandlersMap.put(ResponseType.XML, getXmlResponseHandlerDefault());
  myResponseHandlersMap.put(ResponseType.JSON, getJsonResponseHandlerDefault());
  myResponseHandlersMap.put(ResponseType.TEXT, getTextResponseHandlerDefault());
}
项目:intellij-ce-playground    文件:PivotalTrackerRepository.java   
private HttpMethod doREST(final String request, final HTTPMethod type) throws Exception {
  final HttpClient client = getHttpClient();
  client.getParams().setContentCharset("UTF-8");
  final String uri = getUrl() + request;
  final HttpMethod method = type == HTTPMethod.POST ? new PostMethod(uri) :
                            type == HTTPMethod.PUT ? new PutMethod(uri) : new GetMethod(uri);
  configureHttpMethod(method);
  client.executeMethod(method);
  return method;
}
项目:intellij-ce-playground    文件:PivotalTrackerRepository.java   
@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;
}
项目:intellij-ce-playground    文件:PivotalTrackerRepository.java   
@Override
public void setTaskState(@NotNull Task task, @NotNull TaskState state) throws Exception {
  final String realId = getRealId(task.getId());
  if (realId == null) return;
  final String stateName;
  switch (state) {
    case IN_PROGRESS:
      stateName = "started";
      break;
    case RESOLVED:
      stateName = "finished";
      break;
    // may add some others in future
    default:
      return;
  }
  String url = API_URL + "/projects/" + myProjectId + "/stories/" + realId;
  url += "?" + encodeUrl("story[current_state]") + "=" + encodeUrl(stateName);
  LOG.info("Updating issue state by id: " + url);
  final HttpMethod method = doREST(url, HTTPMethod.PUT);
  final InputStream stream = method.getResponseBodyAsStream();
  final Element element = new SAXBuilder(false).build(stream).getRootElement();
  if (!element.getName().equals("story")) {
    if (element.getName().equals("errors")) {
      throw new Exception(extractErrorMessage(element));
    } else {
      // unknown error, probably our fault
      LOG.warn("Error setting state for: " + url + ", HTTP status code: " + method.getStatusCode());
      throw new Exception(String.format("Cannot set state '%s' for issue.", stateName));
    }
  }
}
项目:r2m-plugin-android    文件:MethodTabPanel.java   
public void createMethodFromExample(RestExampleModel methodModel) {
    // method name
    String methodName = methodModel.getName();
    methodNameSection.getMethodNamePanel().setText(methodName);

    // set verb
    String urlWithVerb = methodModel.getRequestUrl();
    String[] parts = urlWithVerb.split(" ");
    HTTPMethod verb = HTTPMethod.GET;
    if (parts.length > 1) {
        verb = HTTPMethod.valueOf(parts[0]);
    }
    type.selectVerb(verb);

    // set url details (paths/queries
    String templatizedUrl = parts[parts.length - 1];
    methodNameSection.populateUrlDetails(templatizedUrl);

    // Request Headers
    Map<String, String> headers = methodModel.getRequestHeaders();
    if (headers != null && !headers.isEmpty()) {
        header.setEnabled(true);
        for (Map.Entry<String, String> e : headers.entrySet()) {
            header.addHeader(e.getKey(), e.getValue());
        }
    }
    // Request body
    setSectionBody(requestPayloadSection, methodModel.getRequestBody());
    // Response body
    setSectionBody(responsePayloadSection, methodModel.getResponseBody());

}
项目:tools-idea    文件:PivotalTrackerRepository.java   
private HttpMethod doREST(final String request, final HTTPMethod type) throws Exception {
  final HttpClient client = getHttpClient();
  client.getParams().setContentCharset("UTF-8");
  final String uri = getUrl() + request;
  final HttpMethod method = type == HTTPMethod.POST ? new PostMethod(uri) :
                            type == HTTPMethod.PUT ? new PutMethod(uri) : new GetMethod(uri);
  configureHttpMethod(method);
  client.executeMethod(method);
  return method;
}
项目:tools-idea    文件:PivotalTrackerRepository.java   
@Nullable
@Override
public Task findTask(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;
}
项目:consulo-tasks    文件:GenericRepository.java   
public void resetToDefaults() {
  myLoginURL = "";
  myTasksListUrl = "";
  mySingleTaskUrl = "";
  myDownloadTasksInSeparateRequests = false;
  myLoginMethodType = HTTPMethod.GET;
  myTasksListMethodType = HTTPMethod.GET;
  mySingleTaskMethodType = HTTPMethod.GET;
  myResponseType = ResponseType.XML;
  myTemplateVariables = new ArrayList<TemplateVariable>();
  myResponseHandlersMap = new EnumMap<ResponseType, ResponseHandler>(ResponseType.class);
  myResponseHandlersMap.put(ResponseType.XML, getXmlResponseHandlerDefault());
  myResponseHandlersMap.put(ResponseType.JSON, getJsonResponseHandlerDefault());
  myResponseHandlersMap.put(ResponseType.TEXT, getTextResponseHandlerDefault());
}
项目:consulo-tasks    文件:PivotalTrackerRepository.java   
private HttpMethod doREST(final String request, final HTTPMethod type) throws Exception {
  final HttpClient client = getHttpClient();
  client.getParams().setContentCharset("UTF-8");
  final String uri = getUrl() + request;
  final HttpMethod method = type == HTTPMethod.POST ? new PostMethod(uri) :
                            type == HTTPMethod.PUT ? new PutMethod(uri) : new GetMethod(uri);
  configureHttpMethod(method);
  client.executeMethod(method);
  return method;
}
项目:consulo-tasks    文件:PivotalTrackerRepository.java   
@Nullable
@Override
public Task findTask(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;
}
项目:intellij-ce-playground    文件:HttpRequests.java   
@NotNull
public static RequestBuilder head(@NotNull String url) {
  RequestBuilder builder = request(url);
  builder.myMethod = HTTPMethod.HEAD;
  return builder;
}
项目:intellij-ce-playground    文件:GenericRepository.java   
private HttpMethod getHttpMethod(String requestUrl, HTTPMethod type) {
  HttpMethod method = type == HTTPMethod.GET ? new GetMethod(requestUrl) : GenericRepositoryUtil.getPostMethodFromURL(requestUrl);
  configureHttpMethod(method);
  return method;
}
项目:intellij-ce-playground    文件:GenericRepository.java   
public void setLoginMethodType(final HTTPMethod loginMethodType) {
  myLoginMethodType = loginMethodType;
}
项目:intellij-ce-playground    文件:GenericRepository.java   
public void setTasksListMethodType(final HTTPMethod tasksListMethodType) {
  myTasksListMethodType = tasksListMethodType;
}
项目:intellij-ce-playground    文件:GenericRepository.java   
public void setSingleTaskMethodType(HTTPMethod singleTaskMethodType) {
  mySingleTaskMethodType = singleTaskMethodType;
}
项目:intellij-ce-playground    文件:GenericRepository.java   
public HTTPMethod getLoginMethodType() {
  return myLoginMethodType;
}
项目:intellij-ce-playground    文件:GenericRepository.java   
public HTTPMethod getTasksListMethodType() {
  return myTasksListMethodType;
}
项目:intellij-ce-playground    文件:GenericRepository.java   
public HTTPMethod getSingleTaskMethodType() {
  return mySingleTaskMethodType;
}
项目:r2m-plugin-android    文件:RequestModel.java   
public HTTPMethod getHttpMethod() {
    return httpMethod;
}
项目:r2m-plugin-android    文件:Method.java   
public HTTPMethod getHttpMethod() {
    return httpMethod;
}
项目:r2m-plugin-android    文件:Method.java   
public void setHttpMethod(HTTPMethod httpMethod) {
    this.httpMethod = httpMethod;
}
项目:r2m-plugin-android    文件:MethodTypeSection.java   
public void actionPerformed(ActionEvent e) {
    requestPayloadSection.setVisible(true);
    httpMethod = HTTPMethod.POST;
}
项目:r2m-plugin-android    文件:MethodTypeSection.java   
public void actionPerformed(ActionEvent e) {
    requestPayloadSection.setVisible(true);
    httpMethod = HTTPMethod.PUT;
}
项目:r2m-plugin-android    文件:MethodTypeSection.java   
public void actionPerformed(ActionEvent e) {
    requestPayloadSection.setVisible(false);
    requestPayloadSection.clearPayload();
    httpMethod = HTTPMethod.GET;
}
项目:r2m-plugin-android    文件:MethodTypeSection.java   
public void actionPerformed(ActionEvent e) {
    requestPayloadSection.setVisible(false);
    requestPayloadSection.clearPayload();
    httpMethod = HTTPMethod.DELETE;
}
项目:r2m-plugin-android    文件:MethodTypeSection.java   
public HTTPMethod getHttpMethod() {
    return httpMethod;
}
项目:consulo-tasks    文件:GenericRepository.java   
private HttpMethod getHttpMethod(String requestUrl, HTTPMethod type) {
  HttpMethod method = type == HTTPMethod.GET ? new GetMethod(requestUrl) : GenericRepositoryUtil.getPostMethodFromURL(requestUrl);
  configureHttpMethod(method);
  return method;
}
项目:consulo-tasks    文件:GenericRepository.java   
public void setLoginMethodType(final HTTPMethod loginMethodType) {
  myLoginMethodType = loginMethodType;
}
项目:consulo-tasks    文件:GenericRepository.java   
public void setTasksListMethodType(final HTTPMethod tasksListMethodType) {
  myTasksListMethodType = tasksListMethodType;
}
项目:consulo-tasks    文件:GenericRepository.java   
public void setSingleTaskMethodType(HTTPMethod singleTaskMethodType) {
  mySingleTaskMethodType = singleTaskMethodType;
}
项目:consulo-tasks    文件:GenericRepository.java   
public HTTPMethod getLoginMethodType() {
  return myLoginMethodType;
}
项目:consulo-tasks    文件:GenericRepository.java   
public HTTPMethod getTasksListMethodType() {
  return myTasksListMethodType;
}
项目:consulo-tasks    文件:GenericRepository.java   
public HTTPMethod getSingleTaskMethodType() {
  return mySingleTaskMethodType;
}