本文整理汇总了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());
}
}
};
}
示例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());
}
}
};
}