com.atlassian.sal.api.net.Request类的使用及代码示例

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

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

Request介绍

暂无

代码示例

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

public String execute()
    throws ResponseException
{
  return request.execute();
}

代码示例来源: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.plugins.rest/atlassian-rest-module

public JerseyRequest addBasicAuthentication(String hostname, String username, String password) {
  delegateRequest.addBasicAuthentication(hostname, username, password);
  return this;
}

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

private static Request<?, ?> createDefaultRequest(RequestFactoryAdapter requestFactoryAdapter, MethodType methodType, String url) throws CredentialsRequiredException {
  return requestFactoryAdapter.createRequest(methodType, url)
      .setFollowRedirects(true)
      .addHeader(OVERRIDE_HEADER_NAME, OVERRIDE_HEADER_VALUE);
}

代码示例来源:origin: com.atlassian.jira.plugins/jira-dvcs-connector-api

@Override
public void addAuthentication(Request<?, ?> request, String url) {
  request.addHeader("Authorization", "token " + accessToken);
  String separator = url.contains("?") ? "&" : "?";
  url += separator + "access_token=" + getAccessToken();
  request.setUrl(url);
}

代码示例来源:origin: com.atlassian.studio/studio-theme-jira-plugin

@Override
protected String doExecute() throws Exception
{
  String crucibleUrl = getCrucibleUrl();
  if (crucibleUrl == null)
  {
    return SUCCESS;
  }
  Request<?> request = requestFactory.createRequest(Request.MethodType.PUT,
    crucibleUrl + CRUCIBLE_METRICS_REST_ENDPOINT);
  request.addTrustedTokenAuthentication(themeProperties.getSystemAdministrator());
  request.setRequestBody(metrics);
  try
  {
    metrics = request.execute();
  }
  catch (ResponseException re)
  {
    addErrorMessage(getText("crucible.admin.error.response"));
    log.error("Error communicating with Crucible", re);
  }
  return getRedirect("EditMetrics!Default.jspa?message=crucible.admin.info.metrics.updated");
}

代码示例来源:origin: com.atlassian.studio/studio-jira-fisheye-plugin

request.addRequestParameters("url", baseUrl + JIRA_NOTIFICIATION_URL);
request.addTrustedTokenAuthentication();
try
  request.execute();

代码示例来源:origin: com.atlassian.studio/studio-theme-jira-plugin

@Override
public String doDefault() throws Exception
{
  String crucibleUrl = getCrucibleUrl();
  if (crucibleUrl == null)
  {
    return SUCCESS;
  }
  Request<?> request = requestFactory.createRequest(Request.MethodType.GET,
    crucibleUrl + CRUCIBLE_METRICS_REST_ENDPOINT);
  request.addTrustedTokenAuthentication(themeProperties.getSystemAdministrator());
  try
  {
    metrics = request.execute();
  }
  catch (ResponseException re)
  {
    addErrorMessage(getText("crucible.admin.error.response"));
    log.error("Error communicating with Crucible", re);
  }
  return SUCCESS;
}

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

.setConnectionTimeout(CONNECTION_TIMEOUT)
.setSoTimeout(CONNECTION_TIMEOUT)
.setFollowRedirects(false)
.execute(new ResponseHandler()

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

request.addBasicAuthentication("", getFisheyeAdminPassword());
request.execute(responseHandler);

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

public Iterable<ExternalActivityItem> getItems(ApplicationLink appLink, ExternalActivityItemSearchParams params) throws Exception
  {
    final String uri = remoteStreamsFeedUriBuilder.buildUri(appLink, params).toASCIIString();

    try
    {
      final Request<?, ?> request = appLink.createAuthenticatedRequestFactory().createRequest(Request.MethodType.GET, uri);
      request.setConnectionTimeout(CONNECTION_TIMEOUT);
      request.setSoTimeout(SO_TIMEOUT);
      return itemFactory.getItems(request.execute());
    }
    catch (Exception e)
    {
      log.warn("Cannot fetch remote feed from: " + uri);
      throw e;
    }
  }
}

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

private TokenAndSecret requestToken(String url, Request signedRequest)
    throws ResponseException {
  final com.atlassian.sal.api.net.Request tokenRequest = requestFactory.createRequest(com.atlassian.sal.api.net.Request.MethodType.POST, url);
  tokenRequest.addRequestParameters(parameterToStringArray(signedRequest.getParameters()));
  tokenRequest.setFollowRedirects(false);
  tokenRequest.execute(responseHandler);
  final Map<String, String> oAuthParameterMap = oauthParametersHolder.get();

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

@Test
public void testCanSendMultipartPutRequest() throws Exception {
  Server server = new Server(0);
  ServletHandler handler = new ServletHandler();
  handler.addServletWithMapping(SetFilesServlet.class, "/*");
  server.setHandler(handler);
  try {
    // start jetty.
    server.start();
    // now, make a request.
    Request<?, ?> request = requestFactory.createRequest(Request.MethodType.PUT, "http://localhost:" + getActivePort(server));
    request.setFiles(Collections.singletonList(new RequestFilePart(testFile, "testFile")));
    request.execute(new ResponseHandler() {
      public void handle(final Response response) throws ResponseException {
        assertTrue(response.isSuccessful());
      }
    });
  } finally {
    server.stop();
  }
}

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

request.setRequestBody(data, "text/xml");
if (log.isDebugEnabled())
try
  request.execute();

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

.toString());
createLinkBackRequest.setEntity(linkBack);
  createLinkBackRequest.execute(new ResponseHandler<Response>() {
    public void handle(final Response createLinkBackResponse) throws ResponseException {
      if (createLinkBackResponse.getStatusCode() == 201) {

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

/**
 * Fetches consumer information from a remote applinked application, assuming it is running the OAuth plugin.
 *
 * @param applicationLink link to fetch the information from
 * @return Consumer object representing the linked application
 * @throws ResponseException if the fetch fails for any reason
 */
@Nonnull
public static Consumer fetchConsumerInformation(@Nonnull ApplicationLink applicationLink) throws ResponseException {
  final Request<?, ?> request = Anonymous.createAnonymousRequest(applicationLink, Request.MethodType.GET,
      Uris.uncheckedConcatenate(applicationLink.getRpcUrl(), CONSUMER_INFO_PATH).toString());
  request.setHeader("Accept", "application/xml");
  final ConsumerInformationResponseHandler handler = new ConsumerInformationResponseHandler();
  request.execute(handler);
  return handler.getConsumer();
}

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

try {
  final Request<Request<?, Response>, Response> request = requestFactory.createRequest(action, autoConfigUrl.toString());
  request.addHeader(XsrfProtectedServlet.OVERRIDE_HEADER_NAME, XsrfProtectedServlet.OVERRIDE_HEADER_VALUE);
  request.execute(new ResponseHandler<Response>() {
    public void handle(final Response response) throws ResponseException {
      if (response.isSuccessful()) {

代码示例来源: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.sal/sal-ctk-plugin

public void execute(final CtkTestResults results) throws ResponseException
  {
    results.assertTrue("RequestFactory must be injectable", requestFactory != null);

    Request<?, ?> request = requestFactory.createRequest(Request.MethodType.GET, "http://google.com");

    request.execute(new ResponseHandler()
    {
      public void handle(final Response response) throws ResponseException
      {
        passed = response.getResponseBodyAsString().contains("Google");
      }
    });
    results.assertTrue("Should be able to call http://google.com and get result that contains 'google'", passed);

    request = requestFactory.createRequest(Request.MethodType.GET, "http://demo.jira.com");
    request.addSeraphAuthentication("admin", "admin");

    request.execute(new ResponseHandler()
    {
      public void handle(final Response response) throws ResponseException
      {
        passed = response.getResponseBodyAsString().contains("Joe Administrator");
      }
    });
    results.assertTrueOrWarn("Should be able to call http://demo.jira.com and log in using seraph authentication", passed);
  }
}

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

request.setHeader("X-Atlassian-Token", "no-check");
request.setHeader("X-Forwarded-For", xForward != null ? xForward : req.getRemoteAddr());
  if (ctHeader != null)
    request.setHeader("Content-Type", ctHeader);
      params.add(req.getParameter(name));
    request.addRequestParameters((String[]) params.toArray(new String[params.size()]));
    request.setRequestBody(str);

相关文章