@Override public Promise<Response> asyncWithoutCache(@Nonnull AuthorizationGenerator authorizationGenerator, @Nonnull HttpMethod method, @Nonnull URI url, @Nonnull Map<String, String[]> parameters, @Nonnull Map<String, String> headers, @Nonnull InputStream body, @Nonnull String addonKey) { Request.Builder request = httpClient.newRequest(getFullUrl(method, url, parameters)); request.setCacheDisabled(); return async(authorizationGenerator, method, url, parameters, headers, body, addonKey, request); }
private Response getSyncHandlerResponse(String addonKey, URI callbackUri, String jsonEventData, Optional<String> authHeader) throws LifecycleCallbackException { try { Request.Builder request = httpClient.newRequest(callbackUri); request.setCacheDisabled(); request.setAttribute("purpose", "web-hook-notification"); request.setAttribute("pluginKey", addonKey); request.setContentType(MediaType.APPLICATION_JSON); request.setEntity(jsonEventData); if (authHeader.isPresent()) { request.setHeader(AUTHORIZATION_HEADER, authHeader.get()); } request.setHeader(HttpHeaderNames.ATLASSIAN_CONNECT_VERSION, getConnectPluginVersion()); return request.execute(Request.Method.POST).claim(); } catch (Exception e) { log.error("Error contacting remote application at " + callbackUri + " [" + e.getMessage() + "]", e); String message = "Error contacting remote application [" + e.getMessage() + "]"; Throwable cause = e.getCause(); if (cause instanceof UnknownHostException) { throw new LifecycleCallbackBadResponseException(message, "connect.install.error.remote.host.bad.domain", callbackUri.getHost()); } else if (cause instanceof SocketTimeoutException) { throw new LifecycleCallbackBadResponseException(message, "connect.install.error.remote.host.timeout", removeQuery(callbackUri)); } else if (cause instanceof SSLException) { throw new LifecycleCallbackBadResponseException(message, "connect.install.error.remote.host.ssl", removeQuery(callbackUri), cause.getMessage()); } throw new LifecycleCallbackException(message, "connect.remote.upm.install.exception"); } }