}
String url = String.format("%s://%s:%s/v2/apps/%s",
schema, hostname, gatewayPort, appId);
SimpleAsyncHttpClient client = new SimpleAsyncHttpClient.Builder()
.setUrl(url)
.setRequestTimeoutInMs((int) UPLOAD_TIMEOUT)
.setHeader("X-Archive-Name", appArchive.getName())
.setHeader(Constants.Gateway.API_KEY, authToken)
.build();
try {
Future<Response> future = client.put(new LocationBodyGenerator(appArchive));
Response response = future.get(UPLOAD_TIMEOUT, TimeUnit.MILLISECONDS);
if (response.getStatusCode() != 200) {
throw new RuntimeException(response.getResponseBody());
}
return true;
} finally {
client.close();
}
} catch (Exception ex) {
LOG.warn(ex.getMessage(), ex);
throw ex;
}