com.atlassian.sal.api.net.Request.executeAndReturn()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(238)

本文整理了Java中com.atlassian.sal.api.net.Request.executeAndReturn方法的一些代码示例,展示了Request.executeAndReturn的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.executeAndReturn方法的具体详情如下:
包路径:com.atlassian.sal.api.net.Request
类名称:Request
方法名:executeAndReturn

Request.executeAndReturn介绍

暂无

代码示例

代码示例来源:origin: com.atlassian.applinks/applinks-plugin-core

@Override
public <RET> RET executeAndReturn(final ReturningResponseHandler<? super Response, RET> responseHandler)
    throws ResponseException
{
  return (RET) request.executeAndReturn(responseHandler);
}

代码示例来源:origin: com.atlassian.applinks/applinks-plugin-core

public <R> R execute(final ApplicationLinkResponseHandler<R> applicationLinkResponseHandler)
    throws ResponseException
{
  return (R) request.executeAndReturn(applicationLinkResponseHandler);
}

代码示例来源:origin: com.atlassian.applinks/applinks-common

@Override
public <RET> RET executeAndReturn(final ReturningResponseHandler<? super Response, RET> responseHandler)
    throws ResponseException {
  return (RET) request.executeAndReturn(responseHandler);
}

代码示例来源:origin: com.atlassian.applinks/applinks-common

public <R> R execute(final ApplicationLinkResponseHandler<R> applicationLinkResponseHandler)
    throws ResponseException {
  return (R) request.executeAndReturn(applicationLinkResponseHandler);
}

代码示例来源:origin: com.atlassian.plugins.rest/atlassian-rest-module

@Override
public <RET> RET executeAndReturn(final ReturningResponseHandler<? super JerseyResponse, RET> responseHandler) throws ResponseException {
  marshallEntity();
  final Object result = delegateRequest.executeAndReturn(new ReturningResponseHandler<Response, RET>() {
    public RET handle(final Response response) throws ResponseException {
      JerseyResponse res = new JerseyResponse(response, jerseyEntityHandler, plugin);
      return responseHandler.handle(res);
    }
  });
  return (RET) result;
}

代码示例来源:origin: com.atlassian.refapp/platform-ctk-plugin

protected <R> R get(URI uri, final Class<R> resultClass)
    throws ResponseException {
  Request request = createRequestWithBasicAuthentication(uri);
  Object result = request.executeAndReturn(
      new ReturningResponseHandler() {
        public Object handle(Response response) throws ResponseException {
          return response.getEntity(resultClass);
        }
      }
  );
  return (R) result;
}

代码示例来源:origin: com.atlassian.hipchat.plugins/hipchat-core-plugin

@GET
public final Response get(@Context UriInfo uriInfo, @Context HttpHeaders headers, @PathParam("path") String path)
{
  final URI uri = buildUri(path, uriInfo.getQueryParameters());
  logger.info("Getting URI: '{}'", uri);
  final Request<?, com.atlassian.sal.api.net.Response> salRequest = buildSalRequest(uri, headers.getRequestHeaders());
  try
  {
    return salRequest.executeAndReturn(new JaxRsResponseHandler());
  }
  catch (ResponseException e)
  {
    return Response.serverError().entity(e.getMessage()).build();
  }
}

代码示例来源:origin: com.marvelution.atlassian.suite.plugins/atlassian-sonarqube-common

@Override
public ApplicationStatus getStatus(URI url) {
  try {
    LOGGER.debug("Querying " + url + " for its online status.");
    final Request<Request<?, Response>, Response> request =
        requestFactory.createRequest(Request.MethodType.GET, url.toString());
    request.setConnectionTimeout(CONNECTION_TIMEOUT).setSoTimeout(CONNECTION_TIMEOUT);
    return request.executeAndReturn(new ReturningResponseHandler<Response, ApplicationStatus>() {
      @Override
      public ApplicationStatus handle(final Response response) throws ResponseException {
        return response.isSuccessful() || (response.getStatusCode() == HttpStatus.SC_FORBIDDEN) ?
            ApplicationStatus.AVAILABLE : ApplicationStatus.UNAVAILABLE;
      }
    });
  } catch (ResponseException re) {
    return ApplicationStatus.UNAVAILABLE;
  }
}

代码示例来源:origin: com.marvelution.jira.plugins/jira-jenkins-plugin

@Override
public ApplicationStatus getStatus(URI url) {
  try {
    LOGGER.debug("Querying " + url + " for its online status.");
    final Request<Request<?, Response>, Response> request = requestFactory.createRequest(Request.MethodType.GET, url.toString());
    request.setConnectionTimeout(CONNECTION_TIMEOUT).setSoTimeout(CONNECTION_TIMEOUT);
    return request.executeAndReturn(new ReturningResponseHandler<Response, ApplicationStatus>() {
      @Override
      public ApplicationStatus handle(final Response response) throws ResponseException {
        return response.isSuccessful() || (response.getStatusCode() == HttpStatus.SC_FORBIDDEN) || (response.getStatusCode()
            == HttpStatus.SC_UNAUTHORIZED) ? ApplicationStatus.AVAILABLE : ApplicationStatus.UNAVAILABLE;
      }
    });
  } catch (ResponseException re) {
    return ApplicationStatus.UNAVAILABLE;
  }
}

代码示例来源:origin: com.atlassian.applinks/applinks-common

@SuppressWarnings("unchecked")
private void remoteDisableUsingAutoConfigurationServlet(ApplicationLink applink, RequestFactoryAdapter requestFactoryAdapter)
    throws AuthenticationConfigurationException {
  try {
    createDefaultRequest(requestFactoryAdapter, MethodType.DELETE, getAutoConfigServletUrl(applink)).executeAndReturn(LoggingReturningResponseHandler.INSTANCE);
  } catch (ResponseException | CredentialsRequiredException e) {
    throw new AuthenticationConfigurationException(e);
  }
}

代码示例来源:origin: com.atlassian.jira/jira-issue-link-remote-jira-plugin

public RemoteResponse<RemoteJiraIssue> getIssue(final String baseUri, final String issueIdOrKey, final RestVersion restVersion) throws CredentialsRequiredException, ResponseException
{
  final Request<?, Response> request = createGetIssueRequest(baseUri, issueIdOrKey, restVersion);
  final ResponseToIssueConverter jsonConverter = new ResponseToIssueConverter(baseUri, restVersion);
  return request.executeAndReturn(new RestResponseHandler<RemoteJiraIssue>(jsonConverter, restVersion));
}

代码示例来源:origin: com.atlassian.applinks/applinks-plugin-core

/**
   * Does a GET on the baseurl and expects a 200 status code.
   *
   * @param url   baseUrl of the peer.
   * @return
   */
  public ApplicationStatus getStatus(final URI url)
  {
    try
    {
      LOG.debug("Querying " + url + " for its online status.");
      final Request<Request<?, Response>,Response> request = requestFactory
        .createRequest(Request.MethodType.GET, url.toString());
      request.setConnectionTimeout(CONNECTION_TIMEOUT).setSoTimeout(CONNECTION_TIMEOUT);
      return request.executeAndReturn(new ReturningResponseHandler<Response,ApplicationStatus>()
        {
          public ApplicationStatus handle(final Response response) throws ResponseException
          {
            return response.isSuccessful() ?
                ApplicationStatus.AVAILABLE :
                ApplicationStatus.UNAVAILABLE;
          }
        });
    }
    catch (ResponseException re)
    {
      return ApplicationStatus.UNAVAILABLE;
    }
  }
}

代码示例来源:origin: com.atlassian.applinks/applinks-plugin

public boolean isAdminUserInRemoteApplication(final URI url, final String username, final String password)
    throws ResponseException {
  final URI uri = Uris.uncheckedConcatenate(url, RestUtil.REST_APPLINKS_URL);
  final AuthenticationResource restUrl = restUrlBuilder.getUrlFor(uri, AuthenticationResource.class);
  return requestFactory
      .createRequest(Request.MethodType.GET,
          restUrl.getIsAdminUser().toString())
      .addBasicAuthentication(url.getHost(), username, password)
      .executeAndReturn(new ReturningResponseHandler<Response, Boolean>() {
        public Boolean handle(final Response restResponse) throws ResponseException {
          return restResponse.isSuccessful();
        }
      });
}

代码示例来源:origin: com.atlassian.applinks/applinks-common

/**
   * Does a GET on the baseurl and expects a 200 status code.
   *
   * @param url baseUrl of the peer.
   * @return ApplicationStatus for the url
   */
  public ApplicationStatus getStatus(final URI url) {
    try {
      LOG.debug("Querying " + url + " for its online status.");
      final Request<Request<?, Response>, Response> request = requestFactory
          .createRequest(Request.MethodType.GET, url.toString());
      request.setConnectionTimeout(CONNECTION_TIMEOUT).setSoTimeout(CONNECTION_TIMEOUT);
      return request.executeAndReturn(response -> response.isSuccessful() ?
          ApplicationStatus.AVAILABLE :
          ApplicationStatus.UNAVAILABLE);
    } catch (ResponseException re) {
      return ApplicationStatus.UNAVAILABLE;
    }
  }
}

代码示例来源:origin: com.atlassian.applinks/applinks-common

@SuppressWarnings("unchecked")
private void setRemoteStatus(ApplinkOAuthStatus status, ApplicationLink applink, RequestFactoryAdapter requestFactoryAdapter)
    throws ResponseException, CredentialsRequiredException {
  createDefaultJsonRequest(requestFactoryAdapter, MethodType.PUT, getStatusResourceUrl(applink))
      .setEntity(new RestApplinkOAuthStatus(status))
      .executeAndReturn(LoggingReturningResponseHandler.INSTANCE);
}

代码示例来源:origin: com.atlassian.applinks/applinks-common

private void remoteEnableUsingAuthenticationApi(OAuthConfig incoming,
                        OAuthConfig outgoing,
                        ApplicationLink applink,
                        RequestFactoryAdapter requestFactoryAdapter,
                        RemoteApplicationCapabilities capabilities)
    throws AuthenticationConfigurationException {
  try {
    // enable consumer (incoming)
    if (incoming.isEnabled()) {
      createDefaultJsonRequest(requestFactoryAdapter, MethodType.PUT, getAuthenticationConsumerResourceUrl(applink, capabilities))
          .setEntity(getRestConsumer(incoming))
          .executeAndReturn(LoggingReturningResponseHandler.INSTANCE);
    }
    if (outgoing.isEnabled()) {
      String authenticationProviderUrl = getAuthenticationProviderResourceUrl(applink);
      // enable providers (outgoing)
      for (Class<? extends AuthenticationProvider> providerClass : getProviders(outgoing)) {
        createDefaultJsonRequest(requestFactoryAdapter, MethodType.PUT, authenticationProviderUrl)
            .setEntity(new RestAuthenticationProvider(providerClass))
            .executeAndReturn(LoggingReturningResponseHandler.INSTANCE);
      }
    }
  } catch (ResponseException | CredentialsRequiredException e) {
    throw new AuthenticationConfigurationException(e);
  }
}

代码示例来源:origin: com.atlassian.applinks/applinks-plugin

errorListEntity = request
    .setEntity(linkBackToMyself)
    .executeAndReturn(new ReturningResponseHandler<Response, ErrorListEntity>() {
      public ErrorListEntity handle(final Response response) throws ResponseException {

相关文章