当前位置: 首页>>代码示例>>Java>>正文


Java NewBaseRepositoryImpl类代码示例

本文整理汇总了Java中com.intellij.tasks.impl.httpclient.NewBaseRepositoryImpl的典型用法代码示例。如果您正苦于以下问题:Java NewBaseRepositoryImpl类的具体用法?Java NewBaseRepositoryImpl怎么用?Java NewBaseRepositoryImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NewBaseRepositoryImpl类属于com.intellij.tasks.impl.httpclient包,在下文中一共展示了NewBaseRepositoryImpl类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createCancellableConnection

import com.intellij.tasks.impl.httpclient.NewBaseRepositoryImpl; //导入依赖的package包/类
@Nullable
@Override
public CancellableConnection createCancellableConnection() {
  return new NewBaseRepositoryImpl.HttpTestConnection(new HttpGet()) {
    @Override
    protected void test() throws Exception {
      // Strangely, Redmine doesn't return 401 or 403 error codes, if client sent wrong credentials, and instead
      // merely returns empty array of issues with status code of 200. This means that we should attempt to fetch
      // something more specific than issues to test proper configuration, e.g. current user information at
      // /users/current.json. Unfortunately this endpoint may be unavailable on some old servers (see IDEA-122845)
      // and in this case we have to come back to requesting issues in this case to test anything at all.

      URIBuilder uriBuilder = new URIBuilder(getRestApiUrl("users", "current.json"));
      if (isUseApiKeyAuthentication()) {
        uriBuilder.addParameter("key", getAPIKey());
      }
      myCurrentRequest.setURI(uriBuilder.build());
      HttpClient client = getHttpClient();

      HttpResponse httpResponse = client.execute(myCurrentRequest);
      StatusLine statusLine = httpResponse.getStatusLine();
      if (statusLine != null && statusLine.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
        // Check that projects can be downloaded via given URL and the latter is not project-specific
        myCurrentRequest = new HttpGet(getProjectsUrl(0, 1));
        statusLine = client.execute(myCurrentRequest).getStatusLine();
        if (statusLine != null && statusLine.getStatusCode() == HttpStatus.SC_OK) {
          myCurrentRequest = new HttpGet(getIssuesUrl(0, 1, true));
          statusLine = client.execute(myCurrentRequest).getStatusLine();
        }
      }
      if (statusLine != null && statusLine.getStatusCode() != HttpStatus.SC_OK) {
        throw RequestFailedException.forStatusCode(statusLine.getStatusCode(), statusLine.getReasonPhrase());
      }
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:RedmineRepository.java

示例2: createCancellableConnection

import com.intellij.tasks.impl.httpclient.NewBaseRepositoryImpl; //导入依赖的package包/类
@Nullable
@Override
public CancellableConnection createCancellableConnection()
{
	return new NewBaseRepositoryImpl.HttpTestConnection(new HttpGet())
	{
		@Override
		protected void test() throws Exception
		{
			// Strangely, Redmine doesn't return 401 or 403 error codes, if client sent wrong credentials, and instead
			// merely returns empty array of issues with status code of 200. This means that we should attempt to fetch
			// something more specific than issues to test proper configuration, e.g. current user information at
			// /users/current.json. Unfortunately this endpoint may be unavailable on some old servers (see IDEA-122845)
			// and in this case we have to come back to requesting issues in this case to test anything at all.

			URIBuilder uriBuilder = new URIBuilder(getRestApiUrl("users", "current.json"));
			if(isUseApiKeyAuthentication())
			{
				uriBuilder.addParameter("key", getAPIKey());
			}
			myCurrentRequest.setURI(uriBuilder.build());
			HttpClient client = getHttpClient();

			HttpResponse httpResponse = client.execute(myCurrentRequest);
			StatusLine statusLine = httpResponse.getStatusLine();
			if(statusLine != null && statusLine.getStatusCode() == HttpStatus.SC_NOT_FOUND)
			{
				myCurrentRequest = new HttpGet(getIssuesUrl(0, 1, true));
				statusLine = client.execute(myCurrentRequest).getStatusLine();
			}
			if(statusLine != null && statusLine.getStatusCode() != HttpStatus.SC_OK)
			{
				throw RequestFailedException.forStatusCode(statusLine.getStatusCode(), statusLine.getReasonPhrase());
			}
		}
	};
}
 
开发者ID:consulo,项目名称:consulo-tasks,代码行数:38,代码来源:RedmineRepository.java


注:本文中的com.intellij.tasks.impl.httpclient.NewBaseRepositoryImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。